iam having checkboxlist.it is set to autopostback.
intially im showing checkboxlist with everything(Checkbox in chkboxlist) selected. Now im writing Javascript code so tht Minimum One shud be select.
For example : if 3 checkbox in chkboxlist are selected intially.whenver user deselects each checkbox postback occurs.
If user deselects all checkboxed I shud display javascript alert message saying Atleast One shud be selected. I cud able to get aleert message .but i cudnot stop Postback .
Can any1 tell me how to stop postback from javascript ...
mahens
Member
43 Points
118 Posts
Cancel Postback from javascript
Feb 24, 2007 01:47 PM|LINK
Hi,
iam having checkboxlist.it is set to autopostback.
intially im showing checkboxlist with everything(Checkbox in chkboxlist) selected. Now im writing Javascript code so tht Minimum One shud be select.
For example : if 3 checkbox in chkboxlist are selected intially.whenver user deselects each checkbox postback occurs.
If user deselects all checkboxed I shud display javascript alert message saying Atleast One shud be selected. I cud able to get aleert message .but i cudnot stop Postback .
Can any1 tell me how to stop postback from javascript ...
With regards,
m,ahender
Haissam
All-Star
37421 Points
5632 Posts
Re: Cancel Postback from javascript
Feb 24, 2007 09:24 PM|LINK
consider you have the below javascript function
function checkselected()
{
if(your condition)
{
alert('Please select one');
return false;
}
}
now add the below code in the page_load event
CheckBoxList1.Attributes.Add("OnSelectedIndexChanged","return checkselected();");
the return false in the javascript function will stop the postback and you call your function in code behind using the return keyword
HC
MCAD.NET
| Blog |
mahens
Member
43 Points
118 Posts
Re: Cancel Postback from javascript
Feb 26, 2007 03:39 AM|LINK
Hi,
Dude,Its Not wrking can u tell me Another procedure.Possibly tht Event is not there for Checkboxlist in javascript .