include file

  • Thread starter Thread starter NuB
  • Start date Start date
N

NuB

i have an classic asp web app that I'm converting to .NET using C#. The asp
app uses about 20 include files on various pages, in the .NET world can i
use include files or is it web user controls, or something else?
 
how would call a function in the user control from my web form?
example:
if i have a button on my web form, how can i call a function in my user
control to it executes?

webform:
private voit button1_click()
{
// i want to call GetData() that is in my user control.
}

how do i do this?
 
Nub,

There are two different ways that might work best for you.

One would be to put the button in the user control itself. Then the button
click would go directly in the user control's code behind.

If the button has to exist on the page that the user control is contained in
you could use the FindControl method to access the user control.

Put the GetData() routine in your user control and declare the method as
public. Then inside of the button click routine find and cast the user
control something like this:

private void button1_click()

{

// i want to call GetData() that is in my user control.

MyUserControl userControlFound = (MyUserControl)
Page.FindControl("MyUserControlID");

MyUserControl.GetData();

}


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
NuB said:
i have an classic asp web app that I'm converting to .NET using C#.
The asp app uses about 20 include files on various pages, in the .NET
world can i use include files or is it web user controls, or
something else?

Depends. For UI stuff like footers, use web user controls.
However, for function libraries you should create classes
that you can use everywhere.

If you define those classes in a separate project, you need to
"reference" that in your web project.

Hans Kesting
 
Back
Top