我有一个带有密码和确认密码文本框的网络表单.我有一个RegularExpressionValidator附加到第一个,CompareValidator附加到第二个.现在的问题是,当我在密码字段中有内容而确认密码字段中没有任何内容时,它不会显示字段不匹配的错误.只要我在"确认密码"字段中输入内容,就会显示错误.我还想允许将这两个字段留空.
我正在使用.NET 2.0
可能是什么?
我正在向混合WebForms/MVC站点添加一些UI功能.在这种情况下,我将一些AJAX UI功能添加到WebForms页面(通过jQuery),数据来自MVC JsonResult.一切都在100%工作,但有一个例外:
我想实现AntiForgeryToken的XSRF保护.我已经将它与我的纯MVC应用程序上的ValidateAntiForgeryToken属性结合使用,但是想知道如何在WebForms中实现Html.AntiForgeryToken()方法. 以下是使用UrlHelper的示例.
我正确地将ViewContext/RequestContext"模拟"起来有些麻烦.我应该如何在WebForms页面中使用HtmlHelpers?
编辑:我想从我的WebForms页面检索AntiForgeryToken,而不是从MVC JsonResult.
我有一个接受各种数据的表单(通过文本框和复选框列表),在click事件中,他们将所有数据插入表中并选择scope_identity,然后将其存储在变量中,以便在插入checkboxlist项时使用它使用循环到另一个表
根据许多答案和例子,这应该完美!但它给了我这个错误:
Exception Details: System.InvalidCastException: Specified cast is not valid.
Line 66: int NewBrandId = (int)comm.ExecuteScalar();
Run Code Online (Sandbox Code Playgroud)
这是我的linkbutton方法代码:
protected void lnkbtnUploadAndSubmit_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MOODbCenterConnection"].ConnectionString);
SqlCommand comm = new SqlCommand("INSERT INTO Brands (BrandName, BrandLogo, BrandWebsite, IsBrandVisible) VALUES (@Name, @Logo, @Website, @IsVisible); SELECT scope_identity();", conn);
comm.Parameters.Add("@Name", System.Data.SqlDbType.NVarChar, 50);
comm.Parameters["@Name"].Value = txtbxBrandName.Text;
comm.Parameters.Add("@Logo", System.Data.SqlDbType.Text);
comm.Parameters["@Logo"].Value = fileuploadLogo.PostedFile.FileName;
comm.Parameters.Add("@Website", System.Data.SqlDbType.Text);
comm.Parameters["@Website"].Value = txtbxWebsite.Text;
comm.Parameters.Add("@IsVisible", System.Data.SqlDbType.Bit);
comm.Parameters["@IsVisible"].Value = chkbxIsPublished.Checked;
conn.Open();
int NewBrandId = (int)comm.ExecuteScalar();
conn.Close();
foreach (ListItem li in chkbxlstCuisines.Items) …Run Code Online (Sandbox Code Playgroud) 在我的.aspx中,我希望根据来自绑定的值添加一个If语句.我尝试过以下方法:
<% if(bool.Parse(Eval("IsLinkable") as string)){ %>
monkeys!!!!!!
(please be aware there will be no monkeys,
this is only for humour purposes)
<%} %>
Run Code Online (Sandbox Code Playgroud)
IsLinkable是来自Binder的bool.我收到以下错误:
InvalidOperationException
Databinding methods such as Eval(), XPath(), and Bind() can only
be used in the context of a databound control.
Run Code Online (Sandbox Code Playgroud) 昨晚,一位客户打来电话,因为谷歌已经缓存了私人员工信息的版本.除非您登录,否则无法获取相关信息.
他们对Google域名进行了搜索,例如:
site:example.com
Run Code Online (Sandbox Code Playgroud)
并注意到Googled已经抓取并缓存了一些内部页面.
自己查看页面的缓存版本:
这是谷歌的缓存https://example.com/(F(NSvQJ0SS3gYRJB4UUcDa1z7JWp7Qy7Kb76XGu8riAA1idys-nfR1mid8Qw7sZH0DYcL64GGiB6FK_TLBy3yr0KnARauyjjDL3Wdf1QcS-ivVwWrq-htW_qIeViQlz6CHtm0faD8qVOmAzdArbgngDfMMSg_N4u45UysZxTnL3d6mCX7pe2Ezj0F21g4w9VP57ZlXQ_6Rf-HhK8kMBxEdtlrEm2gBwBhOCcf_f71GdkI1))/ViewTransaction.aspx?transactionNumber=12345.它是2013年9月15日格林尼治标准时间00:07:22出现的页面快照
长网址让我很困惑.而不是:
https://example.com/ViewTransaction.aspx?transactionNumber=12345
Run Code Online (Sandbox Code Playgroud)
插入了一个长字符串:
https://example.com/[...snip...]/ViewTransaction.aspx?transactionNumber=12345
Run Code Online (Sandbox Code Playgroud)
我花了几分钟时间记住:这可能是ASP.net "无cookie会话"的症状.如果您的浏览器不支持Set-Cookie,则该网站会在URL中嵌入cookie.
除了我们的网站不使用它.
即使我们的网站确实自动检测到无cookie会话,并且Google设法将网络服务器哄骗在网址中交付会话,它是如何接管另一个用户的会话的呢?
该网站已被机器人抓取多年.而今年5月29日也没有什么不同.
Google通常会通过检查robots.txt文件(我们没有)来开始抓取.但是没有人被允许在robots.txt没有首先进行身份验证的情况下在网站上做任何准备(包括),所以它失败了:
Time Uri Port User Name Status
======== ======================= ==== ================ ======
1:33:04 GET /robots.txt 80 302 ;not authenticated, see /Account/Login.aspx
1:33:04 GET /Account/Login.aspx 80 302 ;use https plesae
1:33:04 GET /Account/Login.aspx 443 200 ;go ahead, try to login
Run Code Online (Sandbox Code Playgroud)
Google一直在寻找robots.txt文件.它永远不会有一个.然后它返回尝试抓取根:
Time Uri Port User Name Status
======== ======================= ==== …Run Code Online (Sandbox Code Playgroud) 在Visual Studio 13的ASP.Net Web表单的默认模板中,有一个标签webopt:
<webopt:bundlereference runat="server" path="~/Content/css" />
Run Code Online (Sandbox Code Playgroud)
搜索后,似乎是捆绑和缩小.标签有官方文档吗?我找不到一个.具体来说我想知道,它是如何工作的?如果Content文件夹中已存在缩小文件,则它将获取该文件.我该如何改变这种行为?路径值如何转换,因为Content文件夹中没有文件夹css?
要求
我正在尝试上传文件,只要用户选择它.我必须满足以下要求:
onchange)事件.目前的代码
以下是我的视图文件的外观:
<asp:UpdatePanel ID="upData" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<div style="width: auto; float: right;">
<asp:Button ID="btnFileImportSkin" CssClass="ButtonSkin AddButton" Text="Import" Style="position: absolute; z-index: 2;" runat="server" OnClientClick="Javascript:onImport(); return false;" />
<asp:FileUpload ID="fileImport" Visible="false" Style="position:relative; opacity:0;" runat="server" onchange="Javascript:onFileSelected();" />
<%-- onchange="Javascript:this.form.submit();" /> --%>
<%-- <asp:Button ID="btnUpload" runat="server" OnClientClick="Javascript:alert('Uploading...'); __doPostBack('<%= btnUpload.ID %>', ''); return false;" /> --%>
<asp:Button ID="btnUpload" OnClick="btnUpload_Click" runat="server" />
</div>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnUpload" />
</Triggers>
</asp:UpdatePanel>
Run Code Online (Sandbox Code Playgroud)
相关的Javascript:
<script type="text/javascript">
function onImport() {
var …Run Code Online (Sandbox Code Playgroud) 不确定我在这里的内容是否可以通过aspnet_compiler.exe工具实现,但是这里是:
我们有一个网站,我们允许用户修改母版页 - 或者说,我们不允许他们直接修改它们,我们给他们一个减少的"标记"样式语言,他们可以用来修改它们这些页面的HTML,所以他们可以基本上"皮肤"该网站看起来像他们自己的前端.
我渴望通过预编译视图和aspx页面来尝试优化网站.但我希望那些视图和页面使用的布局和母版页保持可更新.但是,我无法让它工作......
假设我们有以下aspx页面:
<%@ Page Title="Hello World" MasterPageFile="~/Skinable/Skin.Master" Language="C#" AutoEventWireup="true" CodeBehind="HelloWorld.aspx.cs" Inherits="Project.HelloWorld" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Content" Runat="server">
Hello World!
</asp:Content>
Run Code Online (Sandbox Code Playgroud)
它引用母版页文件Skin.Master中Skinable的文件夹. Skin.Master需要可更新.这是我尝试过的:
如果我只是使用此aspnet_compiler.exe命令编译站点,那么主页面也会被编译,并且不可更新:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe -v / -p d:\SourceFolder d:\CompiledSite
如果我-x Skinable在aspnet_compiler.exe中排除了可换肤文件夹(添加到命令),那么该文件夹不会被复制到输出文件夹,但主页仍然被编译到bin文件夹(即,skin.master.compiled文件生成到构建中)夹).当我们将母版页复制到部署文件夹时,对该文件的更改将被忽略(它只是在编译时使用了母版页).
如果我在运行aspnet_compiler(attrib
+h d:\SourceFolder\Skinable)之前隐藏了Skinable文件夹,那么我得到与上面相同的结果(即通过-x标志排除时)
如果我在运行aspnet_compiler.exe时指定-u标志(Updatable),那么,我不确定它的优点是诚实的,因为似乎没有在该实例中编译,因此编译即时进行当你要求一个页面时,重点是什么......
最后,如果我允许编译所有内容,然后进入bin文件夹并删除skin.master.compiled,那么当您请求使用该母版页的页面时,您会收到错误"文件'Skin.master'没有已预先编译,无法请求"
我怀疑对母版页的引用是这里的问题 - 也就是说,如果一个页面引用了一个母版页,那么如果你想编译页面,那么该母版页也必须编译,但我不确定.我在这里躲起来了吗?
所以我即将开始为我的体育俱乐部开展一个小型项目进行会员注册,我正在尝试在WebForms或MVC之间做出决定.
Allit将是一个用户登录和数据捕获表单(或数据检索),所以我最初用FBA思考WebForms但是我想要暂时玩MVC并且我想它不会是选择太糟糕了.
但是并没有真正掌握MVC的知识,我不知道它是不是错误的适合.
那么,判断WebForms或MVC是否是正确选择的好方法是什么?
我有一个包含ReportViewer控件的Web表单,一个DIV元素,所以我可以看到页面实际渲染.我看到我的页面正确加载,我看到Fiddler中正在访问报表服务,但是从未显示任何内容.
目前,我正在使用带有静态文本的报告,对其没有任何疑问,以确保我将问题隔离开来.
我的页面如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ReportViewer.aspx.cs" Inherits="PeopleNet.Web.Views.Reports.ReportViewer" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/scripts/jquery-1.7.2.js" />
<asp:ScriptReference Path="~/scripts/fixReportViewer.js" />
</Scripts>
</asp:ScriptManager>
<div>
This is the report viewer page...
</div>
<rsweb:ReportViewer ID="ReportViewer1" runat="server"></rsweb:ReportViewer>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
显示报告的代码是:
protected void Page_Load(object sender, EventArgs e)
{
this.ReportViewer1.ServerReport.ReportServerUrl = ConfigurationFacade.ReportServerUri;
this.ReportViewer1.ServerReport.ReportPath = { path to report name };
this.ReportViewer1.ServerReport.ReportServerCredentials = new ReportServerCredentials(); …Run Code Online (Sandbox Code Playgroud) webforms ×10
asp.net ×7
asp.net-mvc ×2
c# ×2
.net ×1
.net-2.0 ×1
ado.net ×1
bind ×1
eval ×1
file-upload ×1
html-helper ×1
if-statement ×1
iis-7.5 ×1
reportviewer ×1
security ×1
sql ×1
sql-server ×1
updatepanel ×1
validation ×1