TheWizardofInt
Well-known member
http://www.123aspx.com/redir.aspx?res=28124
You see that same example all over the Internet
That example does NOT work. You can click the button until your fingernail drops off, and it wont raise an event
Why? Because for whatever reason, there is something in ASP.Net that doesnt let you raise events using the event handler
The CORRECT method is to do this:
Now you have postback and now you can work with the item, and add features like a page.redirect using Java.
Of course, it takes 2 days to find an example like that because you have to wade through all of the other geniuses who read Microsofts "I sure wish it worked like we designed it" manual and then post the solution like it was their own without testing it.
Ok - there. I vented. Carry on
You see that same example all over the Internet
That example does NOT work. You can click the button until your fingernail drops off, and it wont raise an event
Why? Because for whatever reason, there is something in ASP.Net that doesnt let you raise events using the event handler
The CORRECT method is to do this:
Code:
- in the Page load:
Dim sID As String = Me.UniqueID
Dim but As New Button
Page.ClientScript.RegisterHiddenField(sID & _
"_buttonClicked", "")
but.Attributes.Add("onClick", _
"document.forms[0]." & sID & _
"_buttonClicked.value=" & _
but.UniqueID & ";document.forms[0].submit();")
If Not Page.IsPostBack Then
If Request.Item(Me.UniqueID & _
"_buttonClicked").Length > 0 Then
Response.Write("Button " & _
Request.Item(Me.UniqueID & _
"_buttonClicked") & _
" was clicked!")
End If
End If
Now you have postback and now you can work with the item, and add features like a page.redirect using Java.
Of course, it takes 2 days to find an example like that because you have to wade through all of the other geniuses who read Microsofts "I sure wish it worked like we designed it" manual and then post the solution like it was their own without testing it.
Ok - there. I vented. Carry on