Strange comma in Request.Form
-
I have JS function that displays the div container with appropriate userControl for manipulating users permitions. JS funtion:
function ConvertProfessional(id)
{
document.getElementById("userId").value = id;
document.getElementById("adminPermition").style.display = '';
document.getElementById("adminEdit").style.display = 'none';
}It's a table with a bunch of the check boxes and a hidden field where would be stored user id for that particular user. When I click on a link, JS function gets called and displays the div and sets the user id in the hidden field. Hidden field:
<input id="userId" type="hidden" name="userId" />
Then I click on a submit button and with Request.Form["userId"] get that user id. The problem i on the picture. http://img132.imageshack.us/img132/9104/reqds0.jpg[^] Somehow, out of nowhere, comma appears :omg::wtf: I put alert(id) in the JS function and it displays proper value. I also checked with firebug when the page is rendered, and still proper value. This is how I get the value of hidden field and any other control as well. Nothing gremlin in here :).
string uid = Request.Form["userId"];
I don't know what is going on, but since everything is going on, I workaround a problem with this:
uid = uid.Remove(uid.IndexOf(','));
Pretty comfortable :-D.
-
I have JS function that displays the div container with appropriate userControl for manipulating users permitions. JS funtion:
function ConvertProfessional(id)
{
document.getElementById("userId").value = id;
document.getElementById("adminPermition").style.display = '';
document.getElementById("adminEdit").style.display = 'none';
}It's a table with a bunch of the check boxes and a hidden field where would be stored user id for that particular user. When I click on a link, JS function gets called and displays the div and sets the user id in the hidden field. Hidden field:
<input id="userId" type="hidden" name="userId" />
Then I click on a submit button and with Request.Form["userId"] get that user id. The problem i on the picture. http://img132.imageshack.us/img132/9104/reqds0.jpg[^] Somehow, out of nowhere, comma appears :omg::wtf: I put alert(id) in the JS function and it displays proper value. I also checked with firebug when the page is rendered, and still proper value. This is how I get the value of hidden field and any other control as well. Nothing gremlin in here :).
string uid = Request.Form["userId"];
I don't know what is going on, but since everything is going on, I workaround a problem with this:
uid = uid.Remove(uid.IndexOf(','));
Pretty comfortable :-D.
It means you have two controls in the form with the same name of "userId". One is being populated with a value, the other isn't
cheers, Chris Maunder
CodeProject.com : C++ MVP
-
It means you have two controls in the form with the same name of "userId". One is being populated with a value, the other isn't
cheers, Chris Maunder
CodeProject.com : C++ MVP
I didn't knew that and yes, your right. There are two controls with same name, I just checked. Thank you for solving the mystery ;).