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 Value Query

Hi,

I have an e-commerce website written in asp 1.1, vb.net and utilising an access database. Within the database I have a ProductID value to identify each product. Within the following sub procedure I want to be able to reference this value as I want to be able to check if there are enough items in stock. The code below uses the cartitemID and quantity as variables. However to reference individual items in the database I surely will need to pass the ProductID value. How should I approach this ?

[CODE]

Sub dgCart_Update(sender As Object, e As DataGridCommandEventArgs)

Dim intCartitemID As Integer
Dim txtQuantity As TextBox
Dim intQuantity As Integer

'Passes ProductID as sender

'Dim intProductID As Integer ??

intCartitemID = dgCart.DataKeys(e.Item.ItemIndex)
txtQuantity = e.Item.FindControl("txtQuantity")
intQuantity = txtQuantity.Text

'Define intQuantityInStock and reference to CheckQuantity function
Dim intQuantityInStock As Integer = CheckQuantity(intProductID)

'If statement to check enough quantity in stock
If intQuantityInStock < intQuantity
lblError.Text = "This item is currently low in stock. Please select an alternative</b>"
lblError.Visible = True
Else
Dim strSQL As String = "UPDATE [tblCartItems] SET [intQuantityOrder]=@dotnet.itags.org.Quantity WHERE "& _
"intCartitemID = @dotnet.itags.org.intCartitemID"

Dim dbCommand As New OleDbCommand(strSQL, dbConnection)

Dim cmd As New OleDbCommand

dbCommand.Parameters.Add("@dotnet.itags.org.Quantity", intQuantity)
dbCommand.Parameters.Add("@dotnet.itags.org.intCartitemID", intCartitemID)

dbConnection.Open()
dbCommand.ExecuteNonQuery()
dbConnection.Close()

dgCart.EditItemIndex = -1
dgCart.DataSource = DisplayCart()
dgCart.DataBind()

End If

End Sub
[/CODE]

You should be able to set this value in, say the CommandArgument of the button that is being clicked

ex:

<asp:Button
ID="btnAddToCart" runat="server"
CommandArgument='<%# Eval( "ProductID" ) %>'
CommandName="Product"
Text="Add To Cart" />

Then in your code behind, assign intProductID = (int) e.CommandArgument

Depending on what else you are doing with your grid, you may have to wrap an "if" around some code, checking if e.CommandName == "Product"


Thanks - unfortunately I'm not using a button in this instance. How else could I approach it ?


Fixed it thanks

passing value using eventargs

is there a way to pass values using the eventargs of a certain event, lets
say onclick?? or how does everyone else pass values? lets say each button
has 5 things (string, ints, etc) it needs to know, how can you pass that to
the event handler?One option is to utilize the commandarguments argument.
it's a read write property of the control retrievable thru event args ex.
e.commandname

"memememe" <[rem]casolorz[rem]@.hot[rem]mail.com> wrote in message
news:q9iOa.647787$vU3.612940@.news1.central.cox.net ...
> is there a way to pass values using the eventargs of a certain event, lets
> say onclick?? or how does everyone else pass values? lets say each button
> has 5 things (string, ints, etc) it needs to know, how can you pass that
to
> the event handler?
"Alvin Bruney" <vapordan_spam_me_not@.hotmail_no_spamhotmail.com> wrote in
message news:edMGAILRDHA.3144@.tk2msftngp13.phx.gbl...
> One option is to utilize the commandarguments argument.
> it's a read write property of the control retrievable thru event args ex.
> e.commandname
> "memememe" <[rem]casolorz[rem]@.hot[rem]mail.com> wrote in message
> news:q9iOa.647787$vU3.612940@.news1.central.cox.net ...
> > is there a way to pass values using the eventargs of a certain event,
lets
> > say onclick?? or how does everyone else pass values? lets say each
button
> > has 5 things (string, ints, etc) it needs to know, how can you pass that
> to
> > the event handler?

I have used that but it wont solve my problem right now (actually not my
problem, someone elses) because they are using the onlick event of something
other than a button, and it does not have the command event.
Some .Net Event classes contain data in them. It sounds like you might need
to create a custom Event Class and Event Handler delegate, in order to pass
the data you specifically need. Is that correct?

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Some things just happen.
Everything else occurs.

"memememe" <[rem]casolorz[rem]@.hot[rem]mail.com> wrote in message
news:q9iOa.647787$vU3.612940@.news1.central.cox.net ...
> is there a way to pass values using the eventargs of a certain event, lets
> say onclick?? or how does everyone else pass values? lets say each button
> has 5 things (string, ints, etc) it needs to know, how can you pass that
to
> the event handler?
"Kevin Spencer" <kevin@.SPAMMERSSUCKtakempis.com> wrote in message
news:OnHHN2LRDHA.940@.TK2MSFTNGP11.phx.gbl...
> Some .Net Event classes contain data in them. It sounds like you might
need
> to create a custom Event Class and Event Handler delegate, in order to
pass
> the data you specifically need. Is that correct?
> HTH,
> Kevin Spencer
> Microsoft FrontPage MVP
> Internet Developer
> http://www.takempis.com
> Some things just happen.
> Everything else occurs.
> "memememe" <[rem]casolorz[rem]@.hot[rem]mail.com> wrote in message
> news:q9iOa.647787$vU3.612940@.news1.central.cox.net ...
> > is there a way to pass values using the eventargs of a certain event,
lets
> > say onclick?? or how does everyone else pass values? lets say each
button
> > has 5 things (string, ints, etc) it needs to know, how can you pass that
> to
> > the event handler?

that would probably actually work (had considered similar scenarios), i just
hope i can convince the person needing that thats the way to go.
What about creating a class that extends lets say htmlanchor and on the
onclick event it passes something on the event args, or it has some
properties that can be read/write?
As to whether you can successfully override an event handler for an existing
class, you would have to check that class to find out. It's not hard to
create a custom Server Control either.

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Some things just happen.
Everything else occurs.

"memememe" <[rem]casolorz[rem]@.hot[rem]mail.com> wrote in message
news:vUjOa.648127$vU3.216888@.news1.central.cox.net ...
> "Kevin Spencer" <kevin@.SPAMMERSSUCKtakempis.com> wrote in message
> news:OnHHN2LRDHA.940@.TK2MSFTNGP11.phx.gbl...
> > Some .Net Event classes contain data in them. It sounds like you might
> need
> > to create a custom Event Class and Event Handler delegate, in order to
> pass
> > the data you specifically need. Is that correct?
> > HTH,
> > Kevin Spencer
> > Microsoft FrontPage MVP
> > Internet Developer
> > http://www.takempis.com
> > Some things just happen.
> > Everything else occurs.
> > "memememe" <[rem]casolorz[rem]@.hot[rem]mail.com> wrote in message
> > news:q9iOa.647787$vU3.612940@.news1.central.cox.net ...
> > > is there a way to pass values using the eventargs of a certain event,
> lets
> > > say onclick?? or how does everyone else pass values? lets say each
> button
> > > has 5 things (string, ints, etc) it needs to know, how can you pass
that
> > to
> > > the event handler?
> > > that would probably actually work (had considered similar scenarios), i
just
> hope i can convince the person needing that thats the way to go.
> What about creating a class that extends lets say htmlanchor and on the
> onclick event it passes something on the event args, or it has some
> properties that can be read/write?

passing values

hi guys, hello :) im new to asp.net and come from php "gasp" - anyway, i have a list of car categories and when i click an item i want it to populate the datalist with the data, ie - if you click Car1 = select * from Car1.

I already have a search facility, which calls a stored procedure which loads the data by part number. but im not sure how to do this.

the categories are in the same form, so once a category is clicked it loads the data into the same formI'm not sure I follow what the issue is... Having a button postback? Generating the results? Displaying the results?
Hi curt sorry if i confused you

basically i have this function set up

sub loaddata(s as object, e as evenargs)
dim cmd as new sqldataadapter("select * from varCategory", objConn)
objDA.Fill(objDS, "parts")
dgData.Datasource= objDS
dgData.Databind()
objconn.close()

ok now on my form i have a list of cars, and what i want it to do is call this procedure when a car is clicked, and pass on the value of that car to varCategory.

how can i do this?

Hi!

You could call it like this:

Try
cmd =New SqlCommand("usp_TrackUser", objConn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Clear()
cmd.Parameters.Add("@.varCategory", varCategory)
If objConn.State <> ConnectionState.OpenThen objConn.Open()
'execute or asggin to adpater
cmd.ExecuteNonQuery()
Catch exAs System.Exception
'show the error
EndTry

Review the next article:Call a parameterized SP in SQL

Saludos,


What is this "list"? Dropdown? Grid? Etc?

Most controls have an event you can tie to (Click, etc) you can also usually set the control to "autopostback" and allow this event to cause the page to post....

passing values

is there a way to choose which values to
pass to the server when a form is submited?For each form field in the form, a value will be passed.

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

"rpp" <rpsur@.yahoo.com> wrote in message
news:8fccfb65.0312110716.52e2e776@.posting.google.c om...
> is there a way to choose which values to
> pass to the server when a form is submited?

Passing Values

Hi

I have two aspx pages in a frame and in the top page[top frame] i am
creating the controls[TextBox etc..] dynamically and putting in a place
holder. I have a hyperlink in this page[top frame] to populate the data in
the bottom aspx page[bottom frame]. When the user clicks this hyperlink i
need to populate the bottom aspx page[bottom aspx page]based on the user
imputs. So i need to pass the values from the top aspx page [top frame] to
bottom aspx page[bottom frame]. how can i achieve this. Please give some
ideas...

Thanks in AdvanceSince these are just aspx pages, you should be able to the querystring, or
session variables to pass data between the 2 pages.
"Gibs" <dotnet_Gibs@.yahoo.com> wrote in message
news:uHkXScD5DHA.2412@.TK2MSFTNGP09.phx.gbl...
> Hi
> I have two aspx pages in a frame and in the top page[top frame] i am
> creating the controls[TextBox etc..] dynamically and putting in a place
> holder. I have a hyperlink in this page[top frame] to populate the data in
> the bottom aspx page[bottom frame]. When the user clicks this hyperlink i
> need to populate the bottom aspx page[bottom aspx page]based on the user
> imputs. So i need to pass the values from the top aspx page [top frame] to
> bottom aspx page[bottom frame]. how can i achieve this. Please give some
> ideas...
>
> Thanks in Advance
I am using the hyperlink only to redirect the page. more if i am doing a
postback these text box values are not visible.I am getting an error 'Object
reference not set to an instance of an object'. So i am not able to set the
session also.

"Showjumper" <shojumper@.grkjashdjkf.com> wrote in message
news:uHw0LsD5DHA.1040@.TK2MSFTNGP10.phx.gbl...
> Since these are just aspx pages, you should be able to the querystring, or
> session variables to pass data between the 2 pages.
> "Gibs" <dotnet_Gibs@.yahoo.com> wrote in message
> news:uHkXScD5DHA.2412@.TK2MSFTNGP09.phx.gbl...
> > Hi
> > I have two aspx pages in a frame and in the top page[top frame] i am
> > creating the controls[TextBox etc..] dynamically and putting in a place
> > holder. I have a hyperlink in this page[top frame] to populate the data
in
> > the bottom aspx page[bottom frame]. When the user clicks this hyperlink
i
> > need to populate the bottom aspx page[bottom aspx page]based on the
user
> > imputs. So i need to pass the values from the top aspx page [top frame]
to
> > bottom aspx page[bottom frame]. how can i achieve this. Please give some
> > ideas...
> > Thanks in Advance
> I am using the hyperlink only to redirect the page. more if i am doing a
> postback these text box values are not visible.I am getting an error
'Object
> reference not set to an instance of an object'. So i am not able to set
the
> session also.

The error probably means that you ar using a tag like <asp:Textbox
id="txtPipo"> in your aspx file but you do not declare a matching Textbox
object in your codebehind file like

Textbox txtPipo;

As for passing information, you can append all the data as name-value pairs
to the target url you pass to the redirect statement like

http:/someservername?name=pipo%20%address=woonwagen%20%o ccupation=clown

and then retrieve them through Request.QueryString as Showjumper already
suggested.

> "Showjumper" <shojumper@.grkjashdjkf.com> wrote in message
> news:uHw0LsD5DHA.1040@.TK2MSFTNGP10.phx.gbl...
> > Since these are just aspx pages, you should be able to the querystring,
or
> > session variables to pass data between the 2 pages.
> > "Gibs" <dotnet_Gibs@.yahoo.com> wrote in message
> > news:uHkXScD5DHA.2412@.TK2MSFTNGP09.phx.gbl...
> > > Hi
> > > > I have two aspx pages in a frame and in the top page[top frame] i am
> > > creating the controls[TextBox etc..] dynamically and putting in a
place
> > > holder. I have a hyperlink in this page[top frame] to populate the
data
> > > in the bottom aspx page[bottom frame]. When the user clicks this
> > > hyperlink i need to populate the bottom aspx page[bottom aspx page]
> > > based on the user imputs. So i need to pass the values from the top
> > > aspx page [top frame] to bottom aspx page[bottom frame]. how can
> > > i achieve this. Please give some ideas...
You can pass some values via client side code to a control (or hidden
control) in your other frame.
Here's some javascript code that might do the trick for you:
parent.FRAMENAME.document.form1.myhiddentextbox.va lue='test';

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Gibs" <dotnet_Gibs@.yahoo.com> wrote in message
news:uHkXScD5DHA.2412@.TK2MSFTNGP09.phx.gbl...
> Hi
> I have two aspx pages in a frame and in the top page[top frame] i am
> creating the controls[TextBox etc..] dynamically and putting in a place
> holder. I have a hyperlink in this page[top frame] to populate the data in
> the bottom aspx page[bottom frame]. When the user clicks this hyperlink i
> need to populate the bottom aspx page[bottom aspx page]based on the user
> imputs. So i need to pass the values from the top aspx page [top frame] to
> bottom aspx page[bottom frame]. how can i achieve this. Please give some
> ideas...
>
> Thanks in Advance

Passing Values

I know that I can create session variables and pass those values from one
screen to another, but is there not a way to makes variables from one scree
n available to another screen other then session variables? Is there not a
way to create properties in the one screen and then pass some sort of
reference to the screen you are calling?

Can you point me to an example or an article on how to use?

Thanks in advance for your assistance!!!!!!!!Passing Values from Aspx to Aspx

Although ASP.NET usually submits data to the current page for processing,
there are times when you need to pass values from the controls on one page
to controls or routines on another ASP.NET page.
This is a cookbook style tutorial that shows you how to pass from one page
to another. For a deeper explanation, see the Microsoft Help file references
at the bottom of the page.

http://authors.aspalliance.com/kenc/passval.aspx

"Jim Heavey" <JimHeavey@.nospam.com> wrote in message
news:Xns948861B2BA553JimHeaveyhotmailcom@.207.46.24 8.16...
>I know that I can create session variables and pass those values from one
> screen to another, but is there not a way to makes variables from one
> scree
> n available to another screen other then session variables? Is there not
> a
> way to create properties in the one screen and then pass some sort of
> reference to the screen you are calling?
> Can you point me to an example or an article on how to use?
> Thanks in advance for your assistance!!!!!!!!
someone asked exactly the same questions like 10 posts before you so check there