Showing posts with label page. Show all posts
Showing posts with label page. Show all posts

Thursday, March 29, 2012

passing value to another page

hi,

i would like to redirect to customer.aspx from login aspx.

the code is

response.redirect(customer.aspx)

at the same time, i would like to pass the Login ID to customer.aspx. what code should i use for the customer.aspx as well as login.aspx in order to perform such function?

thanks

christeneThere are several options, of which just a few are:

1. Pass it in the URL
2. Store it in a session variable
3. Send it to the user's machine in a cookie.

Hope this helps,
Russ
well.........

my login is a button.
how i implement URL elements in a button control?

how do we use session variable?..i am not sure abt this....

hope u can explain futher...thanks a lot...

christene
What do you mean "My login is a button"? Can you tell me exactly what you have going on?
haha.....it means....

after the user type in the user name n password...they will click on a LOGIN BUTTON in order to log in....

well,i have done some testing using URL and it works...

response.redirect(customer.aspx?cusName = "& CustomerName &"")

on the customer.aspx,

Request.params("cusName")

right?

however, can u pls explain what is session variable?...i have heard about this but not sure what it is and how it works.....can u?

thanks...

christene
There is a good article on MSDN should you passing server control values between pages at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconpassingservercontrolvaluesbetweenpages.asp

Passing values between asp.net pages.

In asp you called a new page and passed any variable information through a query string.
Can some one tell me what the best practice is in asp.net to get information from one asp.net page to another ?

Or at least what the options wereYou can do this exactly as you did in ASP.
If you didn't want to continue using the querystring you could use cookies, sessions, or some other choices. But the querystring in a browser is a querystring in a browser - you can read one or create one just as you always did.

Passing values between contentplaceholders

I have on the same page two ojbectdatasources (ods1, ods2) located in distinct contentplaceholders (CPL1, CPL2). Both are tied to gridviews (grv1, grv2). Objectdatasource ods2 uses grv1 datakey 'ProdCatID' as select parameter. If both ods and grv's are located within the same contentplaceholder, selecting a grv1 value causes ods2 to fire correctly. When the ods and the grv's aremoved to distinct contentplaceholders, firing fails.

Based on the procedure outlined in post: http://forums.asp.net/p/677362/677362.aspx#677362, I tried to substitute 'FormParameter' for 'SelectParameter' to no avail.

Is my code declaration wrong or are there restrictions on using a gridview as select source? (FormField also fails when ods1/grv1 is moved back to the same contentplaceholder.)

TIA for any hints.

1. SelectParameter definition for ods2 when the ods are located in different contentplaceholders with value of 'ctl00$CPL1$grv1' as found in the page html code (does not work):

<SelectParameters> <asp:FormParameter formfield="ctl00$CPL1$grv1" name="ProdCatID" type="Int32"> </asp:FormParameter> </SelectParameters>
2. SelectParameter definition when both ods are located within the same contentplaceholder (works ok):
<asp:ControlParameter controlid="grv1" name="ProdCatID" propertyname="SelectedValue" type="Int32"> </asp:ControlParameter>

Hi Msch,

Based on my understanding, you want to retrieve the data base on the GridView's DataKey value. The GridViews and DataSource controls are in different contentplaceholders. If I have misunderstood you, please feel free to let me know.

If we don't want to place them in the same contentplaceholder, we can bind GridView2 base on the DataKey value of GridView1 in the codebehind. For example:

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">Content1 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"DataKeyNames="ProductID" DataSourceID="SqlDataSource1" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"> <Columns> <asp:BoundField DataField="ProductID" HeaderText="ProductID" ReadOnly="True" SortExpression="ProductID" /> <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" /> <asp:CommandField ButtonType="Button" ShowSelectButton="True" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:aspnetforumConnectionString%>" SelectCommand="SELECT [ProductID], [ProductName] FROM [Production]"></asp:SqlDataSource> <br /></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">Content2 <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID"> <Columns> <asp:BoundField DataField="ProductID" HeaderText="ProductID" ReadOnly="True" SortExpression="ProductID" /> <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" /> <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" /> <asp:BoundField DataField="SupplierName" HeaderText="SupplierName" SortExpression="SupplierName" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:aspnetforumConnectionString%>" SelectCommand="SELECT * FROM [Production] WHERE ([ProductID] = @.ProductID)" OnSelecting="SqlDataSource2_Selecting"> <SelectParameters> <asp:Parameter Name="ProductID" Type="String" /> </SelectParameters> </asp:SqlDataSource></asp:Content>

CodeBehind:

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) {//Executing Select method to bound the GridView2.GridView2.DataSource = SqlDataSource2.Select(DataSourceSelectArguments.Empty); GridView2.DataBind(); }protected void SqlDataSource2_Selecting(object sender, SqlDataSourceSelectingEventArgs e) {//Get the DataKey of GridView1 and then assign to the SqlDataSource's selectparameter.e.Command.Parameters[0].Value = GridView1.DataKeys[GridView1.SelectedIndex][0].ToString(); }


I hope this helps.

Passing values between pages using Forms Authentication

I want to know how can i pass a value from my database to another page using Forms Authentication.

In this example:

1Sub Logon_Click(ByVal senderAs Object,ByVal eAs EventArgs)Handles Submit1.Click23Dim objConnectionAs Data.SqlClient.SqlConnection4Dim objCommandAs Data.SqlClient.SqlCommand5Dim usernameAs String6 Dim passwordAs String7 Dim strSQLQueryAs String8 Dim RecordCountAs Integer910 username = userTextBox.Text11 password = passTextBox.Text1213If Len(Trim(username)) > 0Then14 objConnection =New Data.SqlClient.SqlConnection("Data Source=localhost;" _15 &"Initial Catalog=web_dados;User Id=sa;Password=platinum;" _16 &"Connect Timeout=15;")1718 strSQLQuery ="SELECT * FROM conserto WHERE web_user ='" & username & "' AND web_pass = '" & password & "' "19 objCommand = New Data.SqlClient.SqlCommand(strSQLQuery, objConnection)202122 Try23 objConnection.Open()24 RecordCount = CInt(objCommand.ExecuteScalar())25 Catch ex As Exception26 Finally27 objConnection.Close()28 End Try2930 If RecordCount = 0 Then31 Msg.Text = "Identificação de conserto ou código de acesso inválido."32Else33 FormsAuthentication.RedirectFromLoginPage _34 (userTextBox.Text, Persist.Checked)35End If3637 objConnection.Close()38End If394041 End Sub42

I want to store the value of the field named <numero> of the database, and when the user authenticates, i want to print that variable in the default.aspx page.

You can use a Session variable to do so. If you are using ASP.NET 2.0, then you could use a Profile object too.

Does this help?

Regards


i've just tried to use sessions, but when the user autheticates and are redirected to the default.aspx page, it lost the session value.

1 username = userTextBox.Text2 password = passTextBox.Text3 Session("USERNAME") = username45If Len(Trim(username)) > 0Then6 objConnection =New Data.SqlClient.SqlConnection("Data Source=localhost;" _7 &"Initial Catalog=web_dados;User Id=sa;Password=platinum;" _8 &"Connect Timeout=15;")910 strSQLQuery ="SELECT * FROM conserto WHERE web_user ='" & username & "' AND web_pass = '" & password & "' "11 objCommand = New Data.SqlClient.SqlCommand(strSQLQuery, objConnection)121314 Try15 objConnection.Open()16 RecordCount = CInt(objCommand.ExecuteScalar())17 Catch ex As Exception18 Finally19 objConnection.Close()20 End Try2122 If RecordCount = 0 Then23 Msg.Text = "Identificação de conserto ou código de acesso inválido."24Else2526 FormsAuthentication.RedirectFromLoginPage _27 (userTextBox.Text, Persist.Checked)

in this code in the default.aspx it doesn't display any value.

1Sub Page_Load(ByVal SrcAs Object,ByVal eAs EventArgs)2 userLabel.Text = Session("USERNAME")3End Sub4

why?

passing values between pages (one is previouspage) with asp.net 1.x

i have a page opens a popup in that popup i get some property values for control in the previous page

i need to pass the values to the control vwhen i clik a button

what is the best choise

when i need session i can'nt refresh the previous page correctly so it fails for me (browser asks me a msgbox)

when i want to pass with query string my value is a html tag it allso fails because of security

thanks for helps

i realy need help talk to me guys

Can you clarify the question a bit.

You have a window you pop up that gathers some data that you want to write back to the previous page that the window popped up from?

If so you can use javascript to do it:


function SelectItem(item, invalue)
{
if (window.opener)
if (window.opener.closed == false)
if (window.opener.document && window.opener.document.forms[0] &&
window.opener.document.forms[0].elements[item])
{
window.opener.document.forms[0].elements[item].value = invalue;
}
window.close();
}

Passing values between two pages

Hi

In my source page I am using;

Context.Items("Msg") = Msg
Response.Redirect("Destination_Page.aspx")

In my destination page in Page_Load event I am using;

lblMsg.Text = CType(Context.Items("Msg"), String)

But the value does not get to the destination page. Is there a more
reliable way to pass a string between pages?

Thanks

RegardsTry a Server.Transfer("WebForm2.aspx");
instead of Redirect.

Note this technique does not work if you use Response.Redirect. A Redirect
results in another round trip to the client and a new HTTP request - thus a
new Context object without our ArrayList. To span requests, you'll need to
use the Session object or another state container. Also, there are other
techniques you can use to pass state between two forms when using
Server.Transfer, these other techniques can be found in the resources
section of the article.
http://www.odetocode.com/Articles/111.aspx
"John" <John@.nospam.infovis.co.ukwrote in message
news:eqgC28EpGHA.504@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

Hi
>
In my source page I am using;
>
Context.Items("Msg") = Msg
Response.Redirect("Destination_Page.aspx")
>
In my destination page in Page_Load event I am using;
>
lblMsg.Text = CType(Context.Items("Msg"), String)
>
But the value does not get to the destination page. Is there a more
reliable way to pass a string between pages?
>
Thanks
>
Regards
>
>


If you use Server.Transfer then on the next page you can reference the
PreviousPage object and use the FindControl method to gain reference to
whatever control you want on the previous page (the one that did the
transfer).

--
-Demetri

"sloan" wrote:

Quote:

Originally Posted by

Try a Server.Transfer("WebForm2.aspx");
instead of Redirect.
>
>
Note this technique does not work if you use Response.Redirect. A Redirect
results in another round trip to the client and a new HTTP request - thus a
new Context object without our ArrayList. To span requests, you'll need to
use the Session object or another state container. Also, there are other
techniques you can use to pass state between two forms when using
Server.Transfer, these other techniques can be found in the resources
section of the article.
http://www.odetocode.com/Articles/111.aspx
>
"John" <John@.nospam.infovis.co.ukwrote in message
news:eqgC28EpGHA.504@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

Hi

In my source page I am using;

Context.Items("Msg") = Msg
Response.Redirect("Destination_Page.aspx")

In my destination page in Page_Load event I am using;

lblMsg.Text = CType(Context.Items("Msg"), String)

But the value does not get to the destination page. Is there a more
reliable way to pass a string between pages?

Thanks

Regards


>
>
>

Passing values between Web Forms

Hi,

I have a web page which is split vertically into two by a frame, giving me LeftPage.aspx and RightPage.aspx.

Now then, I want to pass the contents of a few text boxes on LeftPage to some text boxes on RightPage.

How do I do it?

By the way, i'd like the passing to happen at the end of the Page_Load event on LeftPage.

Cheers,
DarrenHello, in the LeftFrame, you specify the link as follows:

Then you name the right frame = "rightFrame". Then, you have used querystrings to pass these values.

regards
Hi,

Thanks for the quick response, however your message does not show any code between your first line and then the line that starts "Then you name..." (i.e. it's blank).

Sorry i'm as thick as a whale omlette when it comes to APS.NET i've only just started... could you be more specific please (i.e. supply code??)

thanks in advance!

regards,
darren
By the way i've tried:

LEFT PAGE CODE:

Server.Transfer("RightPage.aspx")

... but this replaces the left page with the right page inside the left frame!!

regards,
darren


Link text

Replace the 'this' and 'that' with asp variables, or databinders, whatever it is you are using as the values.
Well, I beleive this is the same as my solution, but I didn't get any resposne ?

regards
Use the code that chrisbarr mentioned for the link.
Then in the rightpage.aspx code, use something like (in VB)

If Not Request.Params("a") Is Nothing Then
info = Request.Params("a")
End If

This should collect the information.
Does this help?

Passing values between User Controls

I programmatically add a user control to a page which has a data grid on it. The user can then click on a link button to drill down to detail information.

What I would like to do is unload the existing user control and add the new user control with the data grid showing the detail information.

The question is how do I pass the key values from the existing user control to the new user control ?

Thanks

MarkYou can add your Items to the CurrentContext in order to pass from one control to another or from Page to an control


Context.Items.Add("MyValue", myValue)

To retrieve


Context.Items["MyValue"]

The problem here is when I click on the LinkButton on the DataGrid its going to cause the Parent page to reload itself and in the parents Page_Load subroutine its going to unload the existing Datagrid and load up the User Control with the detail DataGrid on. Therefore, it will never pass through the LinkButton's event to set the Context value.

Unless the secret is to load up both User Controls, on the Post Back, but hide the Header DataGrid ? Or to use client side code to pass the key of the selected record to a hidden field which will get submitted back to the server and be available much sooner in the process ?

I would be interested to here what people think would be the best way of doing this or whether there is a way to still use the Context stuff.

Cheers

Mark
Hi,

you could use a delegate.This article explains it how you could do it.

Grz, Kris.
Here Context is the HttpContext which is always available in a page and user controls. You can use this on the Page Load to store some values and then retrieve it later in the User controls as shown in my previous post.

Passing values between web pages which are in different Web Sites

Hi,
I want to pass information from one page, which is in a site to a page
which is in a different site.
Can I pass an xml file between sites
Thanx
Shankar
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!On Thu, 27 Jan 2005 23:07:58 -0800, Shankar Ayyachamy wrote:

> Hi,
> I want to pass information from one page, which is in a site to a page
> which is in a different site.
> Can I pass an xml file between sites
> Thanx
> Shankar
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!
What about good old query string or form variables?
--
http://dotnetjunkies.com/weblog/dotnut

Thanx,
Other than these two, can we pass a xml file between web sites?
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!
On Fri, 28 Jan 2005 00:58:02 -0800, Shankar Ayyachamy wrote:

> Thanx,
> Other than these two, can we pass a xml file between web sites?
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!
GET/POST are the only ways to access a web-page/send data to it. I think
you need to POST this xml file, using a form variable on the sender page,
and submit it to the second webpage.
HTH
Ranjan
--
http://dotnetjunkies.com/weblog/dotnut
Shankar Ayyachamy <vidshan2@.yahoo.com> confessed in news:eRnB6dRBFHA.4004
@.tk2msftngp13.phx.gbl:

>
> Thanx,
> Other than these two, can we pass a xml file between web sites?
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!
Yes.

Passing values between web pages which are in different Web Sites

Hi,

I want to pass information from one page, which is in a site to a page
which is in a different site.

Can I pass an xml file between sites

Thanx
Shankar

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!On Thu, 27 Jan 2005 23:07:58 -0800, Shankar Ayyachamy wrote:

> Hi,
> I want to pass information from one page, which is in a site to a page
> which is in a different site.
> Can I pass an xml file between sites
> Thanx
> Shankar
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

What about good old query string or form variables?
--

http://dotnetjunkies.com/weblog/dotnut

Thanx,

Other than these two, can we pass a xml file between web sites?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
On Fri, 28 Jan 2005 00:58:02 -0800, Shankar Ayyachamy wrote:

> Thanx,
> Other than these two, can we pass a xml file between web sites?
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

GET/POST are the only ways to access a web-page/send data to it. I think
you need to POST this xml file, using a form variable on the sender page,
and submit it to the second webpage.

HTH
Ranjan
--

http://dotnetjunkies.com/weblog/dotnut
Shankar Ayyachamy <vidshan2@.yahoo.com> confessed in news:eRnB6dRBFHA.4004
@.tk2msftngp13.phx.gbl:

>
> Thanx,
> Other than these two, can we pass a xml file between web sites?
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

Yes.

--

passing values from a web page into windows form application

Hi guys,

How can I pass session/application values from a web page (ASP or
ASP.NET) that is on a host company, into my cliente application?

So I can hide menus based on access permisions once the user makes the
log in in the web page by the application.

I'm using VB.NET with Web Control COM

Thank you

Bruno Alexandre
(Sintra, PORTUGAL)Hi Bruno,

You could post the values to a page from your site containing a vb6
component. The vb6 component would run in-process and with a reference to
the 'Microsoft Active Server Pages Object Library' you could then query the
session and application variables ASPTypeLibrary.Session and
ASPTypeLibrary.Application.
I have a sample program which isfreely available from a demonstration I did
on this a while back available at
http://www.crainiate.net/downloads/vb6wsdemo.zip

This component would then need to notify your application across process's,
there are a number of ways of doing this.

Your client would however need to run IIS, so this solution is limited to
windows2000 or windowsXP.

Kind regards,
James

--
Create interactive flowcharts, diagrams and UML models with ERM3 at
http://www.crainiate.net

"Bruno Alexandre" <bruno.alexandre@.filtrarte.com> wrote in message
news:uWoY6OsoDHA.2188@.TK2MSFTNGP11.phx.gbl...
> Hi guys,
> How can I pass session/application values from a web page (ASP or
> ASP.NET) that is on a host company, into my cliente application?
> So I can hide menus based on access permisions once the user makes the
> log in in the web page by the application.
> I'm using VB.NET with Web Control COM
>
> Thank you
> Bruno Alexandre
> (Sintra, PORTUGAL)

passing values from form to form

I was wondering if it is possible to pass values from one aspx page to another aspx page using properties?

I want to create a property on the 2nd aspx page lets say Name(), and pass in the values from the first aspx page. I know how to pass values like this to a user control, but is it possible to pass it to another aspx page?> I was wondering if it is possible to pass values from one aspx page to another aspx page using properties?

You can sort of do this, but not as directly as you're suggesting.

In your firstpage.aspx:

Public Sub Button_Click( sender As Object, e As EventArgs )
Session( "Name" ) = "Value from textbox, or wherever"
Response.Redirect( "secondpage.aspx" )
End Sub

Then, in your secondpage.aspx:

Private _name As String
Public Property Name As String
Get
Return _name
End Get
Set
_name = Value
End Set
End Property

Public Sub Page_Init( sender As Object, e As EventArgs )
Name = Session( "Name" )
End Sub

If that doesn't help, perhaps you can explain more fully what you're trying to do.
That's what I'm trying to do. I knew that I can use session variables, just wondering if there's any other way to accomplish this.
You can store information into the QueryString as well.
Well, you can't directly access the second Page's properties from the first page, no.

After all, the second Page is not instantiated until the first is destroyed. So there can be no direct messaging between them.

It is for this reason that session variables exist. So, for "form to form" communication, session variables are ideal.

You can also create a single form thatacts like more than one form. If you're trying to keep information "alive" during a certain series of tasks, this might be a better way to go.

Passing values from labels to text boxes via session variables

I'm passing label values from one page to text boxes in another page for user update. I'm using session variables, but I have been unable to display the passed values in the receiving text boxes. I'm not sure if the syntax is wrong or if the constructs are inappropriate. I'm new and need help.

<code>
SENDING PAGE:

<%@dotnet.itags.org. Page Language="vb" %>
<script runat="server"
Sub doSubmit(Source as Object, E as EventArgs)
Context.Items.Add("first", txtFirst.text)
Context.Items.Add("last", txtLast.text)
Server.Transfer("3.aspx")
End Sub

</script>
<html
<head>
<title>1.aspx</title>
</head
<body
<form id="form1" runat="server">
First Name: <asp:TextBox id="txtFirst" runat="server" /><br>
Last Name: <asp:TextBox id="txtLast" runat="server" />
<asp:Button id="button1" Text="Submit" onclick="doSubmit" runat="server" />
</Form>
</body>
</html
RECEIVING PAGE:

<%@dotnet.itags.org. Page Language="vb" %>
<script runat="server"
Sub Page_Load(Source as Object, E as EventArgs)

label1.text = "The Name you entered was : " & Context.Items("first") & " " & _
Context.Items("last")
textbox1.text = Context.Items("First")
textbox2.text = Context.Items("Last")

End Sub

</script>
<html>
<head>
<title>Second Page</title>
<asp:Label ID="label1" runat="server" />
</head>
<body>
<form name="Form1" runat="server">
<asp:TextBox id="textBox1" Text='<%# "textbox1" %>' runat="server"></asp:TextBox>
<asp:TextBox id="textBox2" Text='<%# "textbox2" %>' runat="server"></asp:TextBox>
</form>
</body>
</htmlIn the recieving pae's load event you're setting the value of the textbox so you don't need to bind the text box's value to itself (so just leave out the "Text=' etc." attribute).

Also, the items collection is case sensitive. You're adding items as "first" and "last" but you're trying to retrieve values from "First" and "Last". Choose a case and stick with it and the problem is resolved.
you made my day Chapel21. thanx for the prompt response and the explanation given, it makes a bit clearer what each line of code does.

sometimes I think I should've studied CGI scripting 5 years ago, when i had time to invest. by now, ASP .NET should've been simpler to understand and use, or may be not.. thanx again,

Passing values From One asp.net Page to another

Hello All,

Please helping to understand this .. as i ma novice for .Net
technology..

What are the different possible way to send the value from one to
another in asp.NET using C#.NET ??

I Know only two way ...

1. Through query string.
2. Through session varible.

Apart from above to ways is there any other way to send the value from
one page to another.
Please suggest me if possible share the code...

Thank's and regards
Tarun Sinha"TARUN" <tarun.sinha@.gmail.comwrote in message
news:1190207338.512755.322880@.n39g2000hsh.googlegr oups.com...

Quote:

Originally Posted by

What are the different possible way to send the value from one to
another in asp.NET using C#.NET ??
>
I Know only two way ...
>
1. Through query string.
2. Through session varible.


Yep, either of those will work just fine - what problems are you having...?

Quote:

Originally Posted by

Apart from above to ways is there any other way to send the value from
one page to another.


In ASP.NET 2 you can do cross-page posting:
http://msdn2.microsoft.com/en-us/li...139(vs.80).aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Sometimes you can make use of Page.PreviousPage property.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"TARUN" <tarun.sinha@.gmail.comwrote in message
news:1190207338.512755.322880@.n39g2000hsh.googlegr oups.com...

Quote:

Originally Posted by

Hello All,
>
Please helping to understand this .. as i ma novice for .Net
technology..
>
What are the different possible way to send the value from one to
another in asp.NET using C#.NET ??
>
I Know only two way ...
>
1. Through query string.
2. Through session varible.
>
Apart from above to ways is there any other way to send the value from
one page to another.
Please suggest me if possible share the code...
>
>
Thank's and regards
Tarun Sinha
>


On Sep 19, 6:21 pm, "Mark Rae [MVP]" <m...@.markNOSPAMrae.netwrote:

Quote:

Originally Posted by

"TARUN" <tarun.si...@.gmail.comwrote in message
>
news:1190207338.512755.322880@.n39g2000hsh.googlegr oups.com...
>

Quote:

Originally Posted by

What are the different possible way to send the value from one to
another in asp.NET using C#.NET ??


>

Quote:

Originally Posted by

I Know only two way ...


>

Quote:

Originally Posted by

1. Through query string.
2. Through session varible.


>
Yep, either of those will work just fine - what problems are you having...?
>

Quote:

Originally Posted by

Apart from above to ways is there any other way to send the value from
one page to another.


>
In ASP.NET 2 you can do cross-page posting:http://msdn2.microsoft.com/en-us/li...139(vs.80).aspx
>
--
Mark Rae
ASP.NET MVPhttp://www.markrae.net


But still i am looking for sending the values from one to another
I have been instructed not to use both the way i.e session and quert
string ..
Please suggest the third way for doing this
"TARUN" <tarun.sinha@.gmail.comwrote in message
news:1190208904.393014.322050@.k79g2000hse.googlegr oups.com...

Quote:

Originally Posted by

I have been instructed not to use both the way i.e session and quert
string ..


? Why...?

Quote:

Originally Posted by

Please suggest the third way for doing this


I have already done this - did you not click the hyperlink I suggested...?

--
Mark Rae
ASP.NET MVP
http://www.markrae.net

passing values from main webform to include template pages

View a printable version of this message!I'm new to ASP.Net... I have a web page (myform.aspx) that is put together using 3 include files, header.cscx, left.cscx, & footer.cscx (each has their own .cscx.vb files). I want to assign some custom values on myform.aspx.vb, how can I get these custom values in my one of my includes files, ie. header.cscx.vb?
'**********This is myform.aspx*************
<%@dotnet.itags.org. Register TagPrefix="UC" TagName="footer" src="http://pics.10026.com/?src=footer.ascx"%>
<%@dotnet.itags.org. Register TagPrefix="UC" TagName="left" src="http://pics.10026.com/?src=left.ascx"%>
<%@dotnet.itags.org. Register TagPrefix="UC" TagName="header" src="http://pics.10026.com/?src=header.ascx"%>
<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false" Codebehind="myform.aspx.vb" Inherits="intranet.myform"%>
<UC:header id="header" runat="server" />
<UC:left id="left" runat="server" />
<TABLE><TR><td>My contents go here...</td></TR></TABLE>
<UC:footer id="footer" runat="server" />

'**********This is myform.aspx.vb*************
Public Class myform
Inherits System.Web.UI.Page
Protected WithEvents lblPageTitle As System.Web.UI.WebControls.Label
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblPageTitle.Text = "Welcome to my home page!"
End Sub
End Class

'**********This is header.ascx*************
<%@dotnet.itags.org. Control Language="vb" AutoEventWireup="false" Codebehind="header.ascx.vb" Inherits="intranet.header" %>
'I don't have any HTML code here yet (all are in header.acsx.vb) b/c I'm still working on the sepration between HTML design and codebehind page.

'**********This is header.ascx.vb*************
Public Class header
Inherits System.Web.UI.UserControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'How can I get the value of lblPageTitle here so I can display it in the HTML Title tag??
'I have other values that I want to pass to this page too, but for this example, I'm just trying to get the value of lblPageTitle from myform.aspx.vb
Response.Write("<HTML><HEAD>")
Response.Write("<title>lblPageTitle</title>")
Response.Write("</HEAD><BODY>")
...
End Sub
End Class1) Cookie
2) Session Variable
3) Query String
I think any of these will work for what you're describing. You'retrying to get som value to be accessible to your user controls from themain page.

Have you thought of using properties inside the usercontrols?
check this please:
An Extensive Examination of User Controls
The best reference to UserControls
Regards
Thank you so much, it's exactly what I need!
That is great, Im happy for you.
regards

Monday, March 26, 2012

Passing Values from one page to another

I am passing ID of login user as Session variable and i hv to pass id of one more item and that i m passing in query string.But this is not safe, so how can i encrypt and decrypt that id so if user make some changes in id in addressbar of explorer, it didn't get the data.You can use this link to encrypt the data before putting it in a session variable, then decrypt the data again when you want to read it:

Encryption/Decryption with .NET

regards
But i m not using session variable in 2nd case. Ihv to pass the 2nd id in query string. But i want encryption and decruption for that or is that possible that quesry string not visile to end user.

Passing values from one page to another

I have a Page1.htm with the following code:

<HTML>
<frameset cols="40%,*" >
<frame name="LeftFrame" src='Page2.aspx?Table=??' >
<frame name="RightFrame" >
</frameset>
</HTML
Page1.htm was called using Page1.htm?Table=Users.

I don't know the syntax of how to pass the value of the parameter "Table" onto the second page I'm loading on the LeftFrame, using request.querystring( "Table" ).

I apprecciate any help.

Mosheuse the following:

<frame name="LeftFrame" src='Page2.aspx?Table=<% Response.Write(Request.QueryString("Table"));%>'
Moshe & Sachin

Thanks for your contribution Sachin but the suggestion will not work as it basically an static HTM page as Moshe wrote "I have a Page1.htm with ..." Therfore Response.Write(Request.QueryString("Table")) can't be performed there! An static page would not be able to process this directive. However, the frame file Page2.aspx is able to process all server side code like a normal ASP.NET page.

If you go like src='Page2.aspx?Table=myTable', this will do as its an static parameter. However you can always parse this using java script (it works in static HTML). Try this article
http://www.eggheadcafe.com/articles/20020107.asp

OR make page1.htm (main page) a webform (aspx file) i.e. page1.aspx and this will do as well.

Hope it helps.

-Adnan Masood
Sachin & Adnan,

Thanks very much for the information.

For now I'm implementing the solution keeping Page1.htm as it is and not as a web form, I went to the article Adnan recommended and I already have a function called "queryString()" that is working and returning the value for the parameter "Table" correctly.

Please tell me how to insert the value returned by the javascript function "queryString()" in the code:

<frame name="LeftFrame" src='Page2.aspx?Table=??'
Thanks,
Moshe

Passing values from one page to another

How do I pass values from one page to another without using a button for redirection. That means on my source page I have a hyperlink that redirects to some target page. I have a label on the source page whose text I want to pass to the target page. How can I do that?

Use the querystring.

http://www.codeproject.com/aspnet/QueryString.asp

Passing values between pages

http://www.firoz.name/2006/05/07/passing-values-between-pages/

passing values from page to page

hi,
how can i pass more than one values from one page to another?
thanks> how can i pass more than one values from one page to another?
In more than one way. ;-)
QueryString, Form Post, Session Cache, Application Cache, database, Web
Services, Remoting, Messaging Services...
That's about all I can think of offhand.
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"chris" <anonymous@.discussions.microsoft.com> wrote in message
news:D8BABE4C-0B79-49C0-B93A-14112D9FEB5D@.microsoft.com...
> hi,
> how can i pass more than one values from one page to another?
> thanks
There are a number of different techniques you can use, for example,
passing the values in the queryt string, or in the Context.Items
colletion during a Server.Transfer (see
http://www.odetocode.com/Articles/111.aspx for an example).
HTH,
Scott
http://www.OdeToCode.com
On Mon, 12 Apr 2004 12:21:04 -0700, "chris"
<anonymous@.discussions.microsoft.com> wrote:

>hi,
>how can i pass more than one values from one page to another?
>thanks
Chris,
An easy way to do it is to create a string like so:
string url = "ID=" + varID + "&" + "Name=" + varName;
then your hyperlink should contain something like this:
navigateURL = "destination.aspx?" + url;
Shock
"chris" <anonymous@.discussions.microsoft.com> wrote in message
news:D8BABE4C-0B79-49C0-B93A-14112D9FEB5D@.microsoft.com...
> hi,
> how can i pass more than one values from one page to another?
> thanks

passing values from page to page

hi
how can i pass more than one values from one page to another

thanks> how can i pass more than one values from one page to another?

In more than one way. ;-)

QueryString, Form Post, Session Cache, Application Cache, database, Web
Services, Remoting, Messaging Services...

That's about all I can think of offhand.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"chris" <anonymous@.discussions.microsoft.com> wrote in message
news:D8BABE4C-0B79-49C0-B93A-14112D9FEB5D@.microsoft.com...
> hi,
> how can i pass more than one values from one page to another?
> thanks
There are a number of different techniques you can use, for example,
passing the values in the queryt string, or in the Context.Items
colletion during a Server.Transfer (see
http://www.odetocode.com/Articles/111.aspx for an example).

HTH,

--
Scott
http://www.OdeToCode.com

On Mon, 12 Apr 2004 12:21:04 -0700, "chris"
<anonymous@.discussions.microsoft.com> wrote:

>hi,
>how can i pass more than one values from one page to another?
>thanks
Chris,

An easy way to do it is to create a string like so:

string url = "ID=" + varID + "&" + "Name=" + varName;
then your hyperlink should contain something like this:

navigateURL = "destination.aspx?" + url;

Shock

"chris" <anonymous@.discussions.microsoft.com> wrote in message
news:D8BABE4C-0B79-49C0-B93A-14112D9FEB5D@.microsoft.com...
> hi,
> how can i pass more than one values from one page to another?
> thanks