ASP.net代码背后和来自C#
发布时间:2020-12-16 09:16:57 所属栏目:asp.Net 来源:网络整理
导读:我有一个简单的页面如下: Default.aspx的 %@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %htmlbodyform method="POST" action="Default.aspx"Enter Number: input type="text" name="cNum" value="7707744
我有一个简单的页面如下:
Default.aspx的 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <html> <body> <form method="POST" action="Default.aspx"> Enter Number: <input type="text" name="cNum" value="7707744436276244" /><br /> <input type="submit" value="Submit" /> </form> </body> </html> 和Default.aspx.cs背后的代码 using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { public string ServerSideVariable; protected void Page_Load(object sender,EventArgs e) { string n = String.Format("{0}",Request.Form['cNum']); ERROR Here<--- too many character in character literall.... string pval = "Passed value"; ServerSideVariable = pval; } } 为什么会发生错误? 另外我打算在代码后面实现与DB建立连接并将响应返回给ASP.net,任何人都知道这是怎么做到的? 解决方法
在C#中,’是为字符文字保留的.
“是为字符串文字保留的. char char1 = 'Z'; // Character literal string string1 = "ZZZ"; // String literal C#参考文献: > Character literals 请尝试以下方法: using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { public string ServerSideVariable; protected void Page_Load(object sender,Request.Form["cNum"]); //ERROR Here<--- too many character in character literall.... string pval = "Passed value"; ServerSideVariable = pval; } } 关于第2个问题,请阅读http://www.oracle.com/technetwork/issue-archive/2011/11-sep/o51odt-453447.html. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
推荐文章
站长推荐
- asp.net-mvc-3 – 使用.SetValidator()时,Fluent
- 如何使用WSP将Asp.net Web应用程序部署到Sharepo
- asp.net – 在.aspx主页中包含内容
- asp.net – MathJax – 文件无法加载:/extensio
- asp中select(下拉菜单)如何同时获取value和text的
- asp.net – 在Application_Error中将异常转换为H
- asp.net – Python / web scrape / aspx – 没有
- asp.net – 静态方法中的HttpContext.Current Nu
- asp.net – 弹出窗口,如何在IE8中隐藏URL栏
- vbscript – Classic ASP中的URL编码
热点阅读