-----------------------------------------------------------
New Message on MumbaiUserGroup
-----------------------------------------------------------
From: DankerDevil
Message 6 in Discussion
Hi All ,
I am so glad if you happy with this article...
To create shareable values on the source page
In code, declare one or more read-only properties on the page using standard
syntax for properties. Return the property value you want to pass to the next
page.
The following example shows how you can declare a property called Property1 and
sets its value to the value of text box on the page:
' Visual Basic
Public ReadOnly Property Property1() As String
Get
Return TextBox1.Text
End Get
End Property
// C#
public string Property1
{
get
{
return TextBox1.Text;
}
}
Call the next page by calling the Transfer method of the Server object (the
HttpServerUtility class), passing it the URL of the page you want to pass
information to.
The following example shows how you might call a page called WebForm2 (in the
same project) from an event handler:
' Visual Basic
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Server.Transfer("Webform2.aspx")
End Sub
// C#
private void Button1_Click(object sender, System.EventArgs e)
{
Server.Transfer("Webform2.aspx");
}
To get the property values of the first page from the called page, create an
instance variable of the source page class. You then assign to it the HTTP
object (an instance of the IHttpHandler class), the object that received the
original request.
To read property values from the source page in the called page
Create a global instance variable that is typed to the class of the source
page.
The following example shows how to declare a variable called sourcepage that is
of the type WebForm1:
' Visual Basic
' Put immediately after the Inherits statements
' at the top of the file
Public sourcepage As WebForm1
// C#
// Put immediately after the opening brace of the class
public class WebForm3 : System.Web.UI.Page
{
public WebForm1 sourcepage;
// etc.
In the Page_Load handler, get the source page from the Context.Handler object
(IHttpHandler interface) and assign it to the variable that you created in step
1. You must cast the handler object to the type of the source page class.
Note You should only perform this logic the first time the page runs (that
is, when the page is first called from the source page).
Get the property values from the source page and use them as you would any
object properties.
Note Be sure to save the property values (for example, in view state) if you
want to use them in page processing other than the first page
initialization. For details, see Introduction to Web Forms State Management.
The complete Page_Load handler might look like this:
' Visual Basic
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
sourcepage = CType(Context.Handler, WebForm1)
Label1.Text = sourcepage.Property1
End If
End Sub
// C#
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack){
WebForm1 sourcepage = (WebForm1) Context.Handler;
Label1.Text = sourcepage.Property1;
}
}
Belbinson Toby
Software Engineer
I Antz Solutions
Vazhuthacaud
Thiruvanathapuram
Kerala
Tried the new MSN Messenger? ItÂ’s cool! Download now.
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you
received this message by mistake, please click the "Remove" link below. On the
pre-addressed e-mail message that opens, simply click "Send". Your e-mail
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]