How to add event to Web Form from the vs.net designer

J

James

Hi there,

I know that when i double click a web form I'm taking to the page_load
event. However, I want to create an unload event by I don't know how to
create it from the vs.net designer. Does anybody know how to create a page
unload event from the vs.net designer?



Many thanks
 
J

Jason Hedges

You can use the designer to configure events for the controls on a page
besides the default event you get by double-clicking the control by clicking
the events button on the Properties window for the control and then
double-clicking or typing in the field for the desired event. Unfortunately,
the Page itself does not have this option (see MSDN
http://msdn2.microsoft.com/en-us/library/6w2tb12s(VS.80).aspx).

So, you'll have to create it in code.

For C#, if you have AutoEventWireup="true" in your <%@ Page %> declaration
in the markup, you can put the following in your code to handle the Page
unload event:

protected void Page_UnLoad(object sender, EventArgs e)
{
//Your page unload code here
}

For VB, you can use the drop down box in the upper left corner of the code
window and select "(Page events)" and then select the event you want to
handle from the drop down box in the upper right corner (in this case the
unload event). Visual Studio will then create the procedure for you.

Hope that helps.
Jason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top