Javascript Confirm problem

M

Muhammad Abdullah

Hi
am having some problems with the javascript confirm.
i have it working fine on one page and it doesnt even pop up at the
other.

The code on the working page is,

private void Page_Load(object sender, System.EventArgs e)
{
if(! Page.IsPostBack)
{
DataSet _DSSections =
VariableHandler.GetInstance().FetchAllVariables();
if (_DSSections.Tables[0].Rows.Count > 0)
{
lblInstructions1.Visible = true;
btnEdit.Visible = true;
btnDelete.Visible = true;
btnDelete.Attributes.Add("OnClick","JavaScript:return confirm('Do
you wish to delete the selected variable');");
GrdVariableList.DataSource = _DSSections;
GrdVariableList.DataBind();
}
}
}


The one not working has the same javascript in the same way.

but it doesnt work. Other alerts on the page are showing up. but the
confrim isnt.

When i viewed the source of both the pages i found the following
diference

working:
<input type="submit" name="btnDelete" value="Delete Selected"
onclick="if (typeof(Page_ClientValidate) == 'function')
Page_ClientValidate(); " language="javascript" id="btnDelete"
OnClick="JavaScript:return confirm('Do you wish to delete theselected
variable variable');" style="height:29px;width:100px;" />&nbsp;


Not Working:
<input type="submit" name="btnDelete" value="Delete Selected"
id="btnDelete" OnClick="JavaScript:return confirm('Do you wish to
delete the selected variable');" style="height:29px;width:100px;"
/>&nbsp;


i have no idea when the "iftypeof" thing was added in the first code
and why wasnt it added in the second one.

kindly help me out of this.
thnkx
MA
 
A

avnrao

if you have any custom validation, asp.net throws some client side scripts
to do the validation. thats why you see if(istypeof()) stuff..

but coming to your problem, u mentioned the second peice of code is not
working..infact that should be the one working. and first should not.

when i tried without any custom validators on the page, it gave me the
output like in the second piece of code. it worked.

when i tried with custom validator on the page, it gave me this output which
is correct.
onclick="javascript:return confirm('do you want to delete?');if
(typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); "

Av.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,125
Latest member
VinayKumar Nevatia_
Top