In it there is a user control with an asp.net checkbox. I have to convert the normal checkbox to a three-state checkbox I am trying to write a jquery script. States are called 'check', 'uncheck' and 'intermediate'. The state should be checked by clicking on the intermediate state, clicking on an unchecked condition should change the state to the check, and clicking on the checked state should prevent the situation from being unchecked.
My idea was to be able to include the normal ASP.net checkbox in the page and then call the jquery function to make it a three-state.
This is my jazzery function, which is thick but working:
function SetTriStateCheckBox (checkbox, initial, original CkbxUniqueID) {var i = 0; Var Chaks = $ (CheckboxFender); If (initial) {chks.val (initial); } Chks.hide (). Each (function () {var img = $ ('& lt; img class = "tristate_image" src = "../images / trustimage /' + $ (this) .val () + '$ (this) .attr ( "Checked", ($ (this) .val () == "uncontrolled"? "False": "true"); $ (this) .attr ("name", "input" + + "image" + "image" I); img.ttr ("name", "" + + "image" + i); i ++; $ (this). Earlier (IMG);}); $ ("Tristate_image"). Click (Function () {t = $ ("[name = 'input' '$ (this) .attr (" name ") +"'] "); var tval = t.val (); $ (this). Attr ("src", "../images/tristateimages/" + (wall == "checked"? "Uncheck": "checked") + ".gif"); switch (tawa atr ("check "," True "); break; case" middleman ("Check");} setTimeout ('__ doPostBack (\' '+ originalCkbxUniqueID +' \ ',' '' '),' This is a simplified version of my on-screen event handler, which is a 'true', 'brake; case check': t.val ("uncheck"). 0);});} The startup script registers:
protected override zero OnPreRender (EventArgs e) {string tristatescript = "SetTriStateCheckBox ('Input [id $ = \" ckbx1 \ "]', 'intermediate', ' "+ Ckbx1.UniqueID +" '); "; ScriptManager.RegisterStartupScript (this, GetType ()," ckbx1_tristate ", trustscript, true); base.OnPreRender (E);} everything seems to work properly Except that when I click on my newly inserted image, when I post back, I'm not killing the original handling of the event handler. Page_load hits.
If I remove the part of the .hide () jquery, and click on the original checkbox, request. Perm ['__eventet'] that It is like when the newly inserted image is clicked.
I'm not sure where to go from any suggestion?
I decided to go with it in a different way. It has been found that using a link-button to simulate a three-state checkbox with an image This is very easy for you. It has its own postback event and what you have to do is change the imageurl.
: -)
Comments
Post a Comment