[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Tony Doyle

11/27/2006 2:00:00 PM

All,

Using .NET 1.1, I have built a custom control, however I am having trouble
compiling it.
For the on click event of the button, I want it to run a function that is
already on my aspx page.
As the .NET compiler cannot see this page / function at compile time, does
anyone know of a way I can call the underlying function.

private void ibLogIn_Click( object item, ImageClickEventArgs args )

{

HttpContext.Current.Session["LoggedInAs"] = tbUsername.Text;

SystemLogin(tbUsername.ToString(), tbPassword.ToString());

}

In this case, it's the systemlogin procedure I'm trying to call.

Cheers

Tony


2 Answers

Steve C. Orr, MCSD

11/27/2006 6:07:00 PM

0

Controls shouldn't be tightly coupled with the page on which they are
hosted.
Calling the SystemLogin function may work well for now, but what happens
when you put the control onto another page that doesn't have that function?
It will blow up, that's what! If your response is that you don't ever plan
to put the control onto another page then I'd have to question the wisdom of
creating this functionality as a control in the first place.

Generally it is better for controls to raise events to the page on which
they are hosted, then the page can respond appropriately.
Here's more info:
http://St.../faq/PassDataFromUserCo...

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://St...


"Tony Doyle" <nospam@spamoff.com> wrote in message
news:u1BJgwiEHHA.1220@TK2MSFTNGP04.phx.gbl...
> All,
>
> Using .NET 1.1, I have built a custom control, however I am having trouble
> compiling it.
> For the on click event of the button, I want it to run a function that is
> already on my aspx page.
> As the .NET compiler cannot see this page / function at compile time, does
> anyone know of a way I can call the underlying function.
>
> private void ibLogIn_Click( object item, ImageClickEventArgs args )
>
> {
>
> HttpContext.Current.Session["LoggedInAs"] = tbUsername.Text;
>
> SystemLogin(tbUsername.ToString(), tbPassword.ToString());
>
> }
>
> In this case, it's the systemlogin procedure I'm trying to call.
>
> Cheers
>
> Tony
>

Tony

11/28/2006 8:01:00 PM

0

Steve,

You are right in what you suggest, I have inherited this app from a long
departed developer, so was looking for a way round what he had done.
As it happens, the SystemLogin function is inherited from a separate class
module inside the asp.net application, so I am not expecting it to "blow up"
because of that.
I have found a way to do it, using references,

Thanks

Td


"Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <Steve@Orr.net> wrote in
message news:FDFD3628-1B4F-4E89-8AC7-CB244A7B4460@microsoft.com...
> Controls shouldn't be tightly coupled with the page on which they are
> hosted.
> Calling the SystemLogin function may work well for now, but what happens
> when you put the control onto another page that doesn't have that
> function? It will blow up, that's what! If your response is that you
> don't ever plan to put the control onto another page then I'd have to
> question the wisdom of creating this functionality as a control in the
> first place.
>
> Generally it is better for controls to raise events to the page on which
> they are hosted, then the page can respond appropriately.
> Here's more info:
> http://St.../faq/PassDataFromUserCo...
>
> --
> I hope this helps,
> Steve C. Orr,
> MCSD, MVP, CSM, ASPInsider
> http://St...
>
>
> "Tony Doyle" <nospam@spamoff.com> wrote in message
> news:u1BJgwiEHHA.1220@TK2MSFTNGP04.phx.gbl...
>> All,
>>
>> Using .NET 1.1, I have built a custom control, however I am having
>> trouble compiling it.
>> For the on click event of the button, I want it to run a function that is
>> already on my aspx page.
>> As the .NET compiler cannot see this page / function at compile time,
>> does anyone know of a way I can call the underlying function.
>>
>> private void ibLogIn_Click( object item, ImageClickEventArgs args )
>>
>> {
>>
>> HttpContext.Current.Session["LoggedInAs"] = tbUsername.Text;
>>
>> SystemLogin(tbUsername.ToString(), tbPassword.ToString());
>>
>> }
>>
>> In this case, it's the systemlogin procedure I'm trying to call.
>>
>> Cheers
>>
>> Tony
>>
>