include file

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?
 
N

NuB

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?
 
S

S. Justin Gengo

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
 
H

Hans Kesting

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
 

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,999
Messages
2,570,243
Members
46,835
Latest member
lila30

Latest Threads

Top