Last post Feb 13, 2014 12:40 PM by WishStar99
Feb 05, 2014 11:57 AM|dl0haus|LINK
I have a toggle button that works fine, applied to a CheckBox (ToggleButtonExtender). When I click it, the images change and everything works fine. I have a situation where I need to set the Checked property to true in code. When I do this, the ToggleButton
doesn't reflect this change visually even though the CheckBox is "checked". How do you force this change visually to make it programmatically change its images in accordance with the state of the CheckBox?
Its as if the ToggleButton(Extender) doesn't respond to programmatic changes, only click events. How do you circumvent this?
Feb 05, 2014 07:46 PM|WishStar99|LINK
put the code below in your page load.
strScript += "document.getElementById('" & Me.opnToggle.ClientID & "').checked = true;"
System.Web.UI.ScriptManager.RegisterStartupScript(Me.opnToggle, Me.opnToggle.GetType(), "ToggleButtonExtender_JS", strScript, True)
Feb 05, 2014 11:04 PM|chetan.sarode|LINK
Duplicate thread -
Feb 06, 2014 11:14 AM|dl0haus|LINK
If my CheckBox (with the ToggleButtonExtender) is called chkSendInvitation_1_4
and the ToggleButtonExtender is called tbxSendInvitationExtender
how does it relate to the above code? Also, I'm using C# (sorry for not clarifying this) although any example I can probably convert once I know how the above names in my code relate to the RegisterStartupScript code you posted...
Feb 07, 2014 05:56 PM|WishStar99|LINK
string strScript = "document.getElementById('" & this.chkSendInvitation_1_4.ClientID & "').checked = true;";
System.Web.UI.ScriptManager.RegisterStartupScript(this.chkSendInvitation_1_4, this.chkSendInvitation_1_4.GetType(), "ToggleButtonExtender_JS", strScript, True);
Feb 12, 2014 01:14 PM|dl0haus|LINK
Thanks for your response, this seems to get me closer.
This code definitely changes the state of the button, however doing it int he Page Load is going to be hard because I haven't run the code that actually does anything with the databsa yet. Its almost like I need to manually set this to true and false through
the client code you've provided. This code defintiely changes the state but I might need a more manual solution? Do you have an examples of how to set these toggle button images exactly manually?
Its possible I am doing something wrong as well... the above code does what I need it just doesn't do it based on the database. My DB code iterates through some stuff while building the page dynamically...
Feb 13, 2014 12:40 PM|WishStar99|LINK
I don't have a full view of your code or how you build your page. Are there many togglebuttons? If you create the togglebutton at runtime, instead of setting the checkbox.checked = true; you can also use css.
at run time you can set it: this.checkeboxID.attributes.add("checked",true);