set code for cancel in confirmation box [Resolved]

Posted by Oswaldlily under ASP.NET on 9/28/2011 | Points: 10 | Views : 2091 | Status : [Member] | Replies : 4
I have one link..
If i click link ,I need one confirmation box with ok/cancel
if i click ok,It shd open next window,,
If i click cancel,It shd not open.
I tried the following code..
For both ok and cancel my window opening...
How to set for cancel

<script type="text/javascript">
function getConfirm() {
confirm('Do you want to open excel');

}
</script>

<asp:LinkButton ID="lnk" runat="server" Text="Open window" OnClick="lnk_Click" Visible="true" OnClientClick="return getConfirm()" ></asp:LinkButton> <br />




Responses

Posted by: DotNetguy on: 9/28/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi try this

--------Javascript function-----------

<script type="text/javascript">
function OpenConfirm() {
var checkbox = document.getElementById('<%=chkProduct.ClientID %>');
var isReturn = false;
if (checkbox.checked) {
if (confirm('Do u want to open'))
isReturn = true;
}
else {
alert(' plz click checkbox');
}
return isReturn;
}
</script>

---------html source --------------

<form id="form1" runat="server">
<div>
<asp:CheckBox ID="chkProduct" runat="server" />
<asp:LinkButton ID="lnkConfirm" runat="server" Text="Confirm" OnClientClick="return OpenConfirm()"></asp:LinkButton>
</div>
</form>

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Oswaldlily on: 9/28/2011 [Member] Starter | Points: 25

Up
0
Down
Its very similar to..
In dotnetfunda after posting questions when u click submit it askin
"Do you really want to proceed" if ok,then fine..If cancel-nothin happens..
similarly I expecting

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 9/28/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

This code is enough. Run and test application for checking its working.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Oswaldlily on: 9/28/2011 [Member] Starter | Points: 25

Up
0
Down
hey can u plz help me here?
I have checkboxes

If i uncheck the checkboxes,I need to display confirmation box
lnk.Attributes.Add("onclick", "javascript:return(alert(' plz click checkbox'));")

If i check the checkbox,I need to display box
lnk.Attributes.Add("onclick", "javascript:return(confirm('Do u want to open'));")


Problem here is some refreshment /loading problem i guess..
step1: I unchecked and click link first time-box dint appear.
In my second click,box appears

step 2: now i check the checkboxex and click link,
Box for uncheck displayin 3 or 4 times...

I dint use update panel anywhere ...Am i to use?


Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response