-
September 20th, 2010, 01:49 PM
#1
WithEvents problem
This is ASP.net related, but since the .vb file is giving me the problem I figure this is the board to post on, sorry in advance if it isn't!
So I'm making a Log in type screen for use in a web browser, and I'm having a little bit of a problem with the attached .vb file. I get an error on the line
'Protected WithEvents submit As New Button'
Error says submit is already declared... Although dropping this line gives me a handler error because of the lack of a WithEvents statement...
Heres the larger picture for your understanding:
Public Class _Default
Inherits System.Web.UI.Page
Protected WithEvents submit As New Button
Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click
Dim strscript As String = "<script language='javascript' src='a.js'></script>"
strscript += "<script>"
strscript += "CustomVal()"
strscript += "</script>"
Page.RegisterStartupScript("strscript", strscript)
End Sub
End Class
-
September 20th, 2010, 02:41 PM
#2
Re: WithEvents problem
Why not just change the name of the button?
Always use [code][/code] tags when posting code.
-
September 20th, 2010, 02:44 PM
#3
Re: WithEvents problem
Because the WithEvents has to match the actual name of the button, right? no matter what name i set the button to I'd have to name the WithEvents to the same thing, unless I understand that wrong
-
September 20th, 2010, 06:00 PM
#4
Re: WithEvents problem
If you are defining an object you have control over the name.
Yes the with events is part of the definition and will use the same name.
If the object already exists then you can not define it in this manner as it already exists.
Sounds like you have a button named submit and then are trying to create a new button named submit. This will not work.
Always use [code][/code] tags when posting code.
-
September 21st, 2010, 09:14 AM
#5
Re: WithEvents problem
This is true. I do already have a button called submit... but how do I place the once I'm making in VB.NET then? The exisiting button is an <asp:button> in a particular location on the page, if I can place it through VB I can get rid of the asp one
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
|