I have a JavaScript function in page header for changing visibility of stuffs in the page:
<script type="text/javascript">
// <![CDATA[
function toggleVis(id1, id2, id3) {
var element = document.getElementById(id1).style.visibility;
if (element == 'hidden') {
document.getElementById(id1).style.visibility = 'visible';
document.getElementById(id2).style.visibility = 'visible';
document.getElementById(id3).style.visibility = 'visible';
}
else {
document.getElementById(id1).style.visibility = 'hidden';
document.getElementById(id2).style.visibility = 'hidden';
document.getElementById(id3).style.visibility = 'hidden';
}
}
// ]]>
</script>
It works when I use it in updatepanel with radio button:
<dx:ASPxRadioButton ID="RB1" CssClass="btnInline" runat="server" Text="Yes">
<ClientSideEvents CheckedChanged="function(s, e) { toggleVis('Label33', 'textbox','Label34');}" />
</dx:ASPxRadioButton>
<dx:ASPxLabel ID="Label33" CssClass="btnInline" runat="server" Text="Label33" Style="visibility: hidden" />
<dx:ASPxTextBox ID="textbox" CssClass="btnInline" runat="server" Style="visibility:hidden" Width="40px" />
<dx:ASPxLabel ID="Label34" CssClass="btnInline" runat="server" Text="Label34" Style="visibility: hidden" />
The problem is when I click a button for clearing the form, after that the javascript doesn't work by checking the radio button. I have tried some stuffs that are in the internet, but I couldn't make it, sorry for my english.
Use add_endRequest() . Which will fire in partial callback.
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(toggleVis);
</script>
.aspx
page into <head>
tag. Will work :) Prog is right, When page is partially post back your function will not be called. To make sure this will be call each time u have to call it like: window.onload = function () {toggleVis(id1, id2, id3);Sys.WebForms.PageRequestManager.getInstance().add_endRequest(toggleVis);}; function toggleVis(id1, id2, id3) {}
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.