Hi i have a jquery script which changes the value of button and according to the text value the user insert or updates the record the jquery function works fine the button value is changed but after changing the value the code behind page runs the Add code
is which is by default plz help me following is my jquery script and code
<
script
type="text/javascript">
Sys.Application.add_load(AddUpdate);
$(
$(
$(
});
$(
$(
});
$(
$(
});
});
function AddUpdate() {":input").keydown(function()
{"[id$=_btnOk]").val("Update");":radio").change(function()
{"[id$=_btnOk]").val('Update');"[id$=_drpAcctype]").change(function()
{"[id$=_btnOk]").val('Update');
</
script>
Protected
Sub btnOk_Click(ByVal sender
As
Object,
ByVal e
As EventArgs)
Handles btnOk.ClickSelect btnOk.TextCase
"Add"
Your code is hard to read/follow. You may want to use the code button
{} to paste code in the future.
Anyway, manipulations you do client-side are not visible server-side. So yo umight make use of a hiddenfield and update the value accordingly. You can read the value server-side and do your processing accordingly. So instead of checking btnOk.Text, you
would check hdnField1.Value.
The button text does not goes with form data during postback, you can not capture the change. You can do one thing , take an input hidden text box and when you are changing the text of button save that text in hidden text box and then fetch that textbox
value from server side codebehind.
Thanks for the reply and suggestion and Hey sorry about posting the code in improper way...... instead of getting the hidden value from server side can we change the text of the button on server side using jquery i m rlly new and weak in jquery syntax can
i postback the jquery script and change the text of button so that my code runs according to the tex...t Thanks
You cannot run jQuery through server side it must be run from client side. You need to go with an input controls whose values goes with the form data so that you can get that value in server side.
p.priyank
Member
49 Points
65 Posts
Jquery Button Value not Updating
Oct 08, 2010 10:53 AM|LINK
Hi i have a jquery script which changes the value of button and according to the text value the user insert or updates the record the jquery function works fine the button value is changed but after changing the value the code behind page runs the Add code is which is by default plz help me following is my jquery script and code
<
script type="text/javascript">Sys.Application.add_load(AddUpdate);
$(
$(
$(
});
$(
$(
});
$(
$(
});
});
function AddUpdate() {":input").keydown(function() {"[id$=_btnOk]").val("Update");":radio").change(function() {"[id$=_btnOk]").val('Update');"[id$=_drpAcctype]").change(function() {"[id$=_btnOk]").val('Update');</
script>
Protected Sub btnOk_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnOk.ClickSelect btnOk.TextCase "Add"AddCOA()
'loadAcctv()
Case "Update"UpdateCOA()
End Select
End SubMetalAsp.Net
All-Star
112032 Points
18231 Posts
Moderator
Re: Jquery Button Value not Updating
Oct 08, 2010 12:54 PM|LINK
Your code is hard to read/follow. You may want to use the code button {} to paste code in the future.
Anyway, manipulations you do client-side are not visible server-side. So yo umight make use of a hiddenfield and update the value accordingly. You can read the value server-side and do your processing accordingly. So instead of checking btnOk.Text, you would check hdnField1.Value.
raghav_khung...
All-Star
32835 Points
5563 Posts
MVP
Re: Jquery Button Value not Updating
Oct 08, 2010 12:54 PM|LINK
The button text does not goes with form data during postback, you can not capture the change. You can do one thing , take an input hidden text box and when you are changing the text of button save that text in hidden text box and then fetch that textbox value from server side codebehind.
p.priyank
Member
49 Points
65 Posts
Re: Jquery Button Value not Updating
Oct 09, 2010 05:11 AM|LINK
Thanks for the reply and suggestion and Hey sorry about posting the code in improper way...... instead of getting the hidden value from server side can we change the text of the button on server side using jquery i m rlly new and weak in jquery syntax can i postback the jquery script and change the text of button so that my code runs according to the tex...t Thanks
raghav_khung...
All-Star
32835 Points
5563 Posts
MVP
Re: Jquery Button Value not Updating
Oct 09, 2010 07:36 AM|LINK
You cannot run jQuery through server side it must be run from client side. You need to go with an input controls whose values goes with the form data so that you can get that value in server side.