In VS 2003, I was able to add event handlers in the
InitializeComponent function. In VS 2005, I can no longer see the auto-
generated code.
I tried to add the event handler for a button in the Page_Load event,
bit this did not work.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.SaveBtn.Click += new
EventHandler(this.SaveChanges);
}
}
Could somebody explain why the event handler doesn't register properly
when added in Page_Load event and what the correct procedure is for
adding event handlers in VS 2005 and if there is a way to view the
auto-generated code in VS 2005 ?
Thanks in advance!in vs2005, the form and the code behind are partial classes that are
compiled into one class, instead of using class inheritance. because of
this vs2005 no longer needs the hack of registering its event handles.
event handlers specified in the codebehind, can be accessed from the
form specifiation.
if you want to do your own hookup, it should be done in oninit.
-- bruce (sqlwork.com)
hharry wrote:
Quote:
Originally Posted by
Hello All,
>
In VS 2003, I was able to add event handlers in the
InitializeComponent function. In VS 2005, I can no longer see the auto-
generated code.
>
I tried to add the event handler for a button in the Page_Load event,
bit this did not work.
>
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.SaveBtn.Click += new
EventHandler(this.SaveChanges);
}
}
>
Could somebody explain why the event handler doesn't register properly
when added in Page_Load event and what the correct procedure is for
adding event handlers in VS 2005 and if there is a way to view the
auto-generated code in VS 2005 ?
>
>
Thanks in advance!
>
also i noticed you don't add the event on postback, which is the only
time it would occur.
-- bruce (sqlwork.com)
bruce barker wrote:
Quote:
Originally Posted by
in vs2005, the form and the code behind are partial classes that are
compiled into one class, instead of using class inheritance. because of
this vs2005 no longer needs the hack of registering its event handles.
event handlers specified in the codebehind, can be accessed from the
form specifiation.
>
if you want to do your own hookup, it should be done in oninit.
>
-- bruce (sqlwork.com)
>
>
hharry wrote:
Quote:
Originally Posted by
>Hello All,
>>
>In VS 2003, I was able to add event handlers in the
>InitializeComponent function. In VS 2005, I can no longer see the auto-
>generated code.
>>
>I tried to add the event handler for a button in the Page_Load event,
>bit this did not work.
>>
>protected void Page_Load(object sender, EventArgs e)
> {
> if (!Page.IsPostBack)
> {
> this.SaveBtn.Click += new
>EventHandler(this.SaveChanges);
> }
> }
>>
>Could somebody explain why the event handler doesn't register properly
>when added in Page_Load event and what the correct procedure is for
>adding event handlers in VS 2005 and if there is a way to view the
>auto-generated code in VS 2005 ?
>>
>>
>Thanks in advance!
>>
0 comments:
Post a Comment