This is the html code (part of it):
<input type="hidden" name="Recieved" id="Recieved" value="yuval" />
(the value is recieved from another page, I wrote this just to explain the problem) in the cs (asp) page I get a Null Reference Exception here:
recieve= Request["Recieved"];
if (!recieve.Equals(""))
When I debugged the page and created break point just before the if statement the recieve parameter was null so I think the problem is that the html code is loaded after the asp code and then there is still no Recieved field. I found code that didn't work for me:
protected void Page_Load(object sender, EventArgs e)
{
Page.LoadComplete += new EventHandler(Page_LoadComplete);
}
(after this there is the Page_LoadComplete function code) How can I load the html attributes and set their values before the asp code runs?
Try this in page load
var recieved = Request.Params["Recieved"];
if(!String.IsNullOrEmpty(recieved))
{
// do stuff
}
This code assumes you are sending a param named Recieved using POST or QueryString
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.