calling function from another page in asp.net
Hi
I have a function called addsub() in a.aspx page. i want to call this
addsub() function in b.aspx page. how to call this..? can you guys help me with this..
Thanks,
[191 byte] By [
saidev] at [2007-11-11 8:18:03]

# 1 Re: calling function from another page in asp.net
I'm newbie too, but i think you have to add a reference (create a variable of your web class from your a.aspx), for example:
' VB code
' from a.aspx.vb
Namespace Web1
Class WebForm1
Inherits System.Web.UI.Page
Public Sub AddSub()
' your codes
End Sub
End Class
End NameSpace
' from b.aspx.vb
Namespace Web1
Class WebForm2
Private theVar as WebForm1 = New WebForm1()
Private Sub CallTheFunction()
theVar.AddSub()
End Sub
End Class
End NameSpace
// c# code
// from a.aspx.cs
namespace Web1 {
class WebForm1 : System.Web.UI.Page {
public void AddSub() { // your codes }
}
}
// from b.aspx.cs
namespace Web1 {
class WebForm2 {
private WebForm1 theVar = new WebForm1();
private void callTheFunction() {
theVar.AddSub();
}
}
}
I hope i'm not wrong, i answer with this codes because .NET is pure and fully supported of OOP environment.