i want to use an ajax confirm buttton extender. On researching online, i found that confirm button can be invoked only on click of a button. But my requreiment is that i am doing some calculations in vb.net code behind. Based on some condition, this should
be invoked.
Protected Sub Page_Load(sender As Object, e As EventArgs)
Dim i As Integer = 10
If i < 15 Then
ConfirmButtonExtender1.TargetControlID = "Button2"
Else
ConfirmButtonExtender1.TargetControlID = "Button3"
End If
End Sub
Best wishes,
Please mark the replies as answers if they help or unmark if not.
Feedback to us
If you want to invoke the confirmdialog in the code behind, you can try to follow MetalAsp.Net's advice to use RegisterStartupScript to register the startup script with the Page object at first. When it satisfies certain conditions, the paremeter will be
passed from code behind to javascript and the confirmdialog will pop out.
For details about how to show the confirmdialog according to the parameter, please check the links chetan.sarode provided.
For details about how to use RegisterStartupScript, please check the link below:
heyitsme
Participant
1397 Points
503 Posts
Invoke ajax confirm buttton extender from code behind based on some conditon
Oct 26, 2012 01:45 PM|LINK
i want to use an ajax confirm buttton extender. On researching online, i found that confirm button can be invoked only on click of a button. But my requreiment is that i am doing some calculations in vb.net code behind. Based on some condition, this should be invoked.
ex: dim intAmt as integer =0
if intAmt=0 then
show confirm dialog
else
do nothing
How can i achive this
MetalAsp.Net
All-Star
112718 Points
18367 Posts
Moderator
Re: Invoke ajax confirm buttton extender from code behind based on some conditon
Oct 26, 2012 01:53 PM|LINK
heyitsme
Participant
1397 Points
503 Posts
Re: Invoke ajax confirm buttton extender from code behind based on some conditon
Oct 26, 2012 01:57 PM|LINK
can u please explain with code
chetan.sarod...
All-Star
66569 Points
11265 Posts
Re: Invoke ajax confirm buttton extender from code behind based on some conditon
Oct 27, 2012 04:24 AM|LINK
Hi, Please refer this
http://vincexu.blogspot.com/2008/12/conditionally-display.html
http://forums.asp.net/t/1846333.aspx/1
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
Catherine Sh...
All-Star
23382 Points
2490 Posts
Microsoft
Re: Invoke ajax confirm buttton extender from code behind based on some conditon
Nov 02, 2012 02:13 AM|LINK
Hi,
According to your description, you can change the TargetControlID in the code behind, Please follow the demo below:
In the .aspx
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </asp:ToolkitScriptManager> <asp:Button ID="Button1" runat="server" Text="Button" /> <asp:Button ID="Button2" runat="server" Text="Button" /> <asp:Button ID="Button3" runat="server" Text="Button" /> <asp:ConfirmButtonExtender ID="ConfirmButtonExtender1" BehaviorID="confirmBehavior" runat="server" TargetControlID="Button1" ConfirmText="Are you sure?"> </asp:ConfirmButtonExtender> </div> </form> </body> </html>In the .vb
Best wishes,
Feedback to us
Develop and promote your apps in Windows Store
heyitsme
Participant
1397 Points
503 Posts
Re: Invoke ajax confirm buttton extender from code behind based on some conditon
Nov 02, 2012 07:34 AM|LINK
@Catherine Shan - MSFT: Sorry, I need to invoke confirm dialog based on some condition from code behind, not on click of any button
Catherine Sh...
All-Star
23382 Points
2490 Posts
Microsoft
Re: Invoke ajax confirm buttton extender from code behind based on some conditon
Nov 05, 2012 08:34 AM|LINK
Hi,
So sorry I have misunderstood your meaning.
If you want to invoke the confirmdialog in the code behind, you can try to follow MetalAsp.Net's advice to use RegisterStartupScript to register the startup script with the Page object at first. When it satisfies certain conditions, the paremeter will be passed from code behind to javascript and the confirmdialog will pop out.
For details about how to show the confirmdialog according to the parameter, please check the links chetan.sarode provided.
For details about how to use RegisterStartupScript, please check the link below:
http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.registerstartupscript.aspx
Best wishes,
Feedback to us
Develop and promote your apps in Windows Store