I have a simple page per below:
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>
and code behind 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;
}
}
why the error occuring?
Also i'm planning to implement in code behind to make connectivity with DB and return the response back to ASP.net, any one know how is this done?
In C# the ' is reserved for character literal.
The " is reserved for string literal.
char char1 = 'Z'; // Character literal
string string1 = "ZZZ"; // String literal
C# References:
Try the following:
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;
}
}
As for you second question, please read http://www.oracle.com/technetwork/issue-archive/2011/11-sep/o51odt-453447.html.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With