Partial Class Source Code

Partial Class Source Code

am 29.01.2008 15:55:02 von ChrisFink

I am using VS2008 Pro and having an issue with finding a partial classes
source code so I can modify an event handler that somehow got hosed up.

I have a simple web page that is loading a user control using the
Page.LoadControl method. This usercontrol has an asp:button that is not
firing when clicked, even though the button click event is clearly defined.
I am confident the problem is with the event wiring, however I cannot find
the partial class source code to check/fix this issue. My question is how do
I find and modify the user control's partial class?

If I create a new user control it works fine since the event handler has not
been hosed up like the old one. Although I have a solution, I'd like to find
the root of the problem and understand where the partial class code resides
and how to fix this directly.

Partial classes are handy, however, we still need the ability to work with
the generated code....rarely, but the need still arises.

Thanks

RE: Partial Class Source Code

am 29.01.2008 19:04:02 von brucebarker

the aspcompiler compiles the aspx page straight to a dll (no source code).
event hookup is pretty simple for click events. you just specify the handler
name, and the page compile generates the hookup.

as you are dynamically loading the user control, its probably a coding error
on your part. either you are not loading the control early enough on postback
or the control name is different on postback, so the triggering control is
not found (as its name is different)

-- bruce (sqlwork.com)


"Chris Fink" wrote:

> I am using VS2008 Pro and having an issue with finding a partial classes
> source code so I can modify an event handler that somehow got hosed up.
>
> I have a simple web page that is loading a user control using the
> Page.LoadControl method. This usercontrol has an asp:button that is not
> firing when clicked, even though the button click event is clearly defined.
> I am confident the problem is with the event wiring, however I cannot find
> the partial class source code to check/fix this issue. My question is how do
> I find and modify the user control's partial class?
>
> If I create a new user control it works fine since the event handler has not
> been hosed up like the old one. Although I have a solution, I'd like to find
> the root of the problem and understand where the partial class code resides
> and how to fix this directly.
>
> Partial classes are handy, however, we still need the ability to work with
> the generated code....rarely, but the need still arises.
>
> Thanks

RE: Partial Class Source Code

am 30.01.2008 16:36:00 von ChrisFink

Hi Bruce,

Thank You for your response. I now agree that this is a coding issue,
however, I do not know the correct resolution.

Following is a code snippet.

protected void Page_Load(object sender, EventArgs e)
{
//Clear the control place holders
phStatus.Controls.Clear();

// the control's btn click event works fine from here
//LoadStatus("123");

// if querystring is present, load the form in read only mode
// another page has a querystring link that points to this page
if (Request["id"] != null)
{
LoadForm106(Request.QueryString["id"].ToString());
// But when i try to load the user control from here, the btn
does not fire
LoadStatus("123");
EnableControls(false);
}
}

protected void LoadStatus(string RequestGUID)
{
StatusApprovalControl uc =
(StatusApprovalControl)Page.LoadControl("~/controls/StatusAp provalControl.ascx");
uc.ID = "ucStatusApproval";
phStatus.Controls.Add(uc);
}

Essentially what I have here is a data entry form that contains a status
placeholder named phStatus. On initial page load, phStatus not loaded. A
user clicks on the form's submit button and is redirected to a success.aspx
page that displays a link+querystring back to the data entry form. This
querystring is then used to load the form as ready only and also dynamically
loads the StatusApprovalControl.ascx for the first time into the phStatus
placeholder. All works fine except the buttons in the StatusApprovalControl
do not fire.

If this code is insufficient to present the problem, could you please
elaborate on some additional things I should look for. I've tried to load
the control on the Page OnInit with the same results.

protected override void OnInit(EventArgs e)
{
base.OnInit(e);

//Clear the control place holders
phStatus.Controls.Clear();

if (Request["id"] != null)
{
LoadForm106(Request.QueryString["id"].ToString());
LoadStatus(Request.QueryString["id"].ToString());
EnableControls(false);
}
}

The triggering control's name is also set on Page Load but it is most likely
this is the root of my problem but I'm not sure what I need to do to fix it.

Thanks for your help

"bruce barker" wrote:

> the aspcompiler compiles the aspx page straight to a dll (no source code).
> event hookup is pretty simple for click events. you just specify the handler
> name, and the page compile generates the hookup.
>
> as you are dynamically loading the user control, its probably a coding error
> on your part. either you are not loading the control early enough on postback
> or the control name is different on postback, so the triggering control is
> not found (as its name is different)
>
> -- bruce (sqlwork.com)
>
>
> "Chris Fink" wrote:
>
> > I am using VS2008 Pro and having an issue with finding a partial classes
> > source code so I can modify an event handler that somehow got hosed up.
> >
> > I have a simple web page that is loading a user control using the
> > Page.LoadControl method. This usercontrol has an asp:button that is not
> > firing when clicked, even though the button click event is clearly defined.
> > I am confident the problem is with the event wiring, however I cannot find
> > the partial class source code to check/fix this issue. My question is how do
> > I find and modify the user control's partial class?
> >
> > If I create a new user control it works fine since the event handler has not
> > been hosed up like the old one. Although I have a solution, I'd like to find
> > the root of the problem and understand where the partial class code resides
> > and how to fix this directly.
> >
> > Partial classes are handy, however, we still need the ability to work with
> > the generated code....rarely, but the need still arises.
> >
> > Thanks

RE: Partial Class Source Code

am 31.01.2008 19:09:04 von ChrisFink

Issue resolved. I had a validator on the parent page causing the control
not to postback. Once I cleared the validation the user control worked as
planned.

My instinct told me it wasn't something to do with the naming or timing of
the usercontrol load...but sometimes when applications get big you tend to
overlook the obvious.

Thanks for your help

"Chris Fink" wrote:

> Hi Bruce,
>
> Thank You for your response. I now agree that this is a coding issue,
> however, I do not know the correct resolution.
>
> Following is a code snippet.
>
> protected void Page_Load(object sender, EventArgs e)
> {
> //Clear the control place holders
> phStatus.Controls.Clear();
>
> // the control's btn click event works fine from here
> //LoadStatus("123");
>
> // if querystring is present, load the form in read only mode
> // another page has a querystring link that points to this page
> if (Request["id"] != null)
> {
> LoadForm106(Request.QueryString["id"].ToString());
> // But when i try to load the user control from here, the btn
> does not fire
> LoadStatus("123");
> EnableControls(false);
> }
> }
>
> protected void LoadStatus(string RequestGUID)
> {
> StatusApprovalControl uc =
> (StatusApprovalControl)Page.LoadControl("~/controls/StatusAp provalControl.ascx");
> uc.ID = "ucStatusApproval";
> phStatus.Controls.Add(uc);
> }
>
> Essentially what I have here is a data entry form that contains a status
> placeholder named phStatus. On initial page load, phStatus not loaded. A
> user clicks on the form's submit button and is redirected to a success.aspx
> page that displays a link+querystring back to the data entry form. This
> querystring is then used to load the form as ready only and also dynamically
> loads the StatusApprovalControl.ascx for the first time into the phStatus
> placeholder. All works fine except the buttons in the StatusApprovalControl
> do not fire.
>
> If this code is insufficient to present the problem, could you please
> elaborate on some additional things I should look for. I've tried to load
> the control on the Page OnInit with the same results.
>
> protected override void OnInit(EventArgs e)
> {
> base.OnInit(e);
>
> //Clear the control place holders
> phStatus.Controls.Clear();
>
> if (Request["id"] != null)
> {
> LoadForm106(Request.QueryString["id"].ToString());
> LoadStatus(Request.QueryString["id"].ToString());
> EnableControls(false);
> }
> }
>
> The triggering control's name is also set on Page Load but it is most likely
> this is the root of my problem but I'm not sure what I need to do to fix it.
>
> Thanks for your help
>
> "bruce barker" wrote:
>
> > the aspcompiler compiles the aspx page straight to a dll (no source code).
> > event hookup is pretty simple for click events. you just specify the handler
> > name, and the page compile generates the hookup.
> >
> > as you are dynamically loading the user control, its probably a coding error
> > on your part. either you are not loading the control early enough on postback
> > or the control name is different on postback, so the triggering control is
> > not found (as its name is different)
> >
> > -- bruce (sqlwork.com)
> >
> >
> > "Chris Fink" wrote:
> >
> > > I am using VS2008 Pro and having an issue with finding a partial classes
> > > source code so I can modify an event handler that somehow got hosed up.
> > >
> > > I have a simple web page that is loading a user control using the
> > > Page.LoadControl method. This usercontrol has an asp:button that is not
> > > firing when clicked, even though the button click event is clearly defined.
> > > I am confident the problem is with the event wiring, however I cannot find
> > > the partial class source code to check/fix this issue. My question is how do
> > > I find and modify the user control's partial class?
> > >
> > > If I create a new user control it works fine since the event handler has not
> > > been hosed up like the old one. Although I have a solution, I'd like to find
> > > the root of the problem and understand where the partial class code resides
> > > and how to fix this directly.
> > >
> > > Partial classes are handy, however, we still need the ability to work with
> > > the generated code....rarely, but the need still arises.
> > >
> > > Thanks