0

Is it possible to create Event (for example Button click event) from Source View? I mean without going to design view ?

1
  • In short, the answer is yes, but to get an appropriate answer, we'll need to know what language you are coding in? Commented Jun 4, 2010 at 11:09

3 Answers 3

1

In your code, you create your method:

protected void Button1_Click(object sender, EventArgs e)
{

}

And in your markup (not the design view), you add your button:

<asp:Button runat="server" OnClick="Button1_Click" />

That should be it.

Sign up to request clarification or add additional context in comments.

1 Comment

In VB.net, you can use the 'handles' syntax at the end of a method declaration.
1

Additionally you can add an event handler dynamically in Codebehind f.e.(VB.Net):

AddHandler Me.Button1.Click, AddressOf Me.Button1_Click

Comments

0

You need to create an eventhandler and assign a method to it.

ButtonId.click += new EventHandler(Button1_Click);

protected void Button1_Click(object sender, EventArgs e)
{

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.