when i access my hidden variable from my code behind iam getting the value as 0 instead of failed ,i checked by putting alert,its entering into the if loop.so no problem there.
function CheckDllsTxt() {
$('select').each(function () {
if (($(this).val()) == '-1') {
document.getElementById('<%=HdnValidation.ClientID%>').value = 'Failed';
}
});
i placed it both inside and outside of the update panel
C#:
i placed it both inside and outside of the update panel
C#:
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertUser", "CheckDllsTxt();", true);
if (HdnValidation.Value == "Failed")
{
}
else
{
}
the Function CheckDllsTxt(); is also invoking,but iam getting HdnValidation.Value=0,pls help me out
the Function CheckDllsTxt(); is also invoking,but iam getting HdnValidation.Value=0,pls help me out
Abhishek JainPosted Aug 30, 2013, 1:31 AM
First of all please make sure that you are trying to access the updated value in Hidden Field on postback, if you trying this on the very first page load then you will always get value "0" because you have initially set it to "0"
See this:
Now once the page will get rendered on the browser your javascript method will be executed and the value will be set to "Failed". No on postback you can retrieve the value of Hidden Field.
Also please make sure that you are not setting the value every time before accessing it, means on very first load and on postback(In your code behind).
Last but not the lease please check for this page the key you are providing in statement this:
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertUser", "CheckDllsTxt();", true);
Key here is "alertUser"
It should be unique please make sure you are not registering any other method with the same key.
Thanks
AJ
Sanjeeb LenkaPosted Aug 30, 2013, 12:34 AM
Can you provide more details. what is your requirement. what value you want to store in hiddenfield.
Nitesh KejriwalPosted Aug 29, 2013, 11:55 AM