|
-
Jun 28th, 2006, 05:53 AM
#1
Thread Starter
Hyperactive Member
Javascript:Confirm button
I've got a question: the following ASP.NET code works fully in my testproject. When I click my htmlbutton (defined protected withevents, not seeable in the code), I get a messagebox asking me what to do. Clicking yes fires the htmlbutton event, clicking no ignores it.
This is the code:
VB Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
With btn
.InnerText = "Apply"
.ID = "Button1"
'.Attributes.Add("runat", "server")
.Visible = True
End With
Me.Controls.Add(btn)
btn.Attributes.Add("OnClick", "javascript:if(confirm('Are you sure?') == false) return false;")
End Sub
Private Sub btn_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn.ServerClick
Response.Write("OK")
End Sub
The problem is that I can't get it to work in my real project. The confirm message is shown, if I click cancel nothing happens, and if I click ok, something happens, but the underlying event is not fired.
Could it be that the button is added to a placeholder control dynamically? Or that the button is placed within a table?
Hope anyone could help, thanx in advance,
JMvVliet
-
Jun 28th, 2006, 07:44 PM
#2
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|