I have a question about web forms.
I've set up a web service and i'm now trying to make a registration page.
The one thing I couldn't figure out is how to handle events. For example, I have a simple button with id="Register", how can I handle that event?
I can't seem to call a textbox on my form like you usually do in a VB form.
Can somebody guide me through the basics? Perhaps a link for newbies?
Googling for information isn't as easy as I thought it would be :(
1 Year Ago
Related Article:VB Web Service - how to handle sessions?
is a solved VB.NET discussion thread by selman555 that has 1 reply, was last updated 1 year ago and has been tagged with the keywords: sessions, vb, webservice.
Any controls that you place on the page (the .aspx) that you want to use server side need to have an ID and the attribute runat="server". You can then access on the code-behind page by using its ID.
For example, if you had a text box :
<asp:Textbox id="textBox1" runat="server" />
It could be accessed with:
textBox1.Text = "Hello World"
If a control is clickable (such as a radio button, button, etc) you also need to specify the onCLick="someMethod()" in the .aspx page and then include the same method in the code behind. For a button it would be:
<asp:Button id="button1" runat="server" text="Click me" onCLick="button1_Click" />
sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
I hope that helps. The MSDN site is pretty useful when starting out (or at any other time...)
@kingsonprisonic: I want to create server-sided event handling, but I would like an example of eventhandling in jscript too if possible?
@hericles: Thanks for the info, altough I'm still having trouble, here's some code
So i've managed to create a sub for btnAanmelden (which is btnloggin in english by the way), but intellisense doesn't detect the two textboxes above the button.
As you can see, they are all server side. Here's what i've got in VB (code behind)
Sub btnAanmelden_Click(ByVal Sender As Object, ByVal e As EventArgs)
txtGebruikersnaam.Text = "test"
txtGebruikersnaam gives me an error saying that it has not been declared and it might be due to it's protection level.
Alright... pretty stupid of me but I found what was going wrong.
I imported my aspx pages and masterpages from a normal website project.
I copied most of the code to new pages and masterpages and everything is working as I expected :)