Showing posts with label asp. Show all posts
Showing posts with label asp. 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 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

Passing values across webforms that use Master pages

Sorry to create a new thread on an old post but I didn't get a viable answer
and thought that the odds were against me getting one unless I started a new
thread.

My question was this:

I want to pass a string variable from default3.aspx to default2.aspx.

I create a property in default2.aspx, called "X", and assign a value. I then
call Server.Transfer("default3.aspx")

In default3.aspx I have this code:
Dim Default3 As Default3 = ctype(Context.Handler, Default3)
Dim PassedString As String = Default3.x

This will work fine as long a default 3 is not a webform that references a
master page.

If it is, it tells me that "Default 3" is an undefined type. As a result,
the only way that I know o get it to work is to turn of Option Strict and
change it to this:

Dim Default3 As Object = Context.Handler
Dim PassedString As String = Default3.x

I really dont want to turn off Option Strict or resort to looselt typed
variables.

How do I correct this?
Chad,
Try either putting the String name=value combo on the querystring, or into
the HttpContext.Current.Items Collection. Not reasonable to expect a
"property" of a page to survive a server.transfer or Response.Redirect.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com

"Chad" wrote:

> Sorry to create a new thread on an old post but I didn't get a viable answer
> and thought that the odds were against me getting one unless I started a new
> thread.
> My question was this:
> I want to pass a string variable from default3.aspx to default2.aspx.
> I create a property in default2.aspx, called "X", and assign a value. I then
> call Server.Transfer("default3.aspx")
> In default3.aspx I have this code:
> Dim Default3 As Default3 = ctype(Context.Handler, Default3)
> Dim PassedString As String = Default3.x
> This will work fine as long a default 3 is not a webform that references a
> master page.
> If it is, it tells me that "Default 3" is an undefined type. As a result,
> the only way that I know o get it to work is to turn of Option Strict and
> change it to this:
> Dim Default3 As Object = Context.Handler
> Dim PassedString As String = Default3.x
> I really dont want to turn off Option Strict or resort to looselt typed
> variables.
> How do I correct this?
>
>
>
>
>
Actually, it does work if you define Default3 as an Object. I was trying to
strongly type the variable Default3 as an object of type "Default3" and it
did not recognize the class "Defaulyt3" outside of the Default3 class.

Try it. It does work.

"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.nospammin.com> wrote in message
news:C28C574E-44C8-4903-B81A-8A970605CBAA@.microsoft.com...
> Chad,
> Try either putting the String name=value combo on the querystring, or into
> the HttpContext.Current.Items Collection. Not reasonable to expect a
> "property" of a page to survive a server.transfer or Response.Redirect.
> Peter
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
> "Chad" wrote:
>> Sorry to create a new thread on an old post but I didn't get a viable
>> answer
>> and thought that the odds were against me getting one unless I started a
>> new
>> thread.
>>
>> My question was this:
>>
>> I want to pass a string variable from default3.aspx to default2.aspx.
>>
>> I create a property in default2.aspx, called "X", and assign a value. I
>> then
>> call Server.Transfer("default3.aspx")
>>
>> In default3.aspx I have this code:
>> Dim Default3 As Default3 = ctype(Context.Handler, Default3)
>> Dim PassedString As String = Default3.x
>>
>> This will work fine as long a default 3 is not a webform that references
>> a
>> master page.
>>
>> If it is, it tells me that "Default 3" is an undefined type. As a result,
>> the only way that I know o get it to work is to turn of Option Strict and
>> change it to this:
>>
>> Dim Default3 As Object = Context.Handler
>> Dim PassedString As String = Default3.x
>>
>> I really dont want to turn off Option Strict or resort to looselt typed
>> variables.
>>
>> How do I correct this?
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>

Passing values between 2 open pages (eg. parent and dialog)

Can someone tell me if there is another way of passing variables back and forth between 2 open pages (such as in the case of a dialog window) without using javascript.

I have done it before using javascript but now that I am using a lot of user controls on my pages I find it a pain in the butt with how the user controls are being named, especially when you have multiple nested controls.

Any help would be greatly appreciated.
Thanks.You could use session variables, but this would require that each of the pages involved do a postback in order to be able to read the session variables. Otherwise, javascript is your best bet.
Alright, thanks mendhak, just thought I would check to see if there was a better way.

Passing Values and Server.Transfer

Hello all.
With a background in ASP, I am finding the work required for passing
values between pages mystifying. For various obvious reasons, I have
eliminated using cookies and session to store state data. The only
ASP.NET options left is to use the Server.Transfer to transfer to page
2 from page 1, and then use the context to get whatever values in page
1 from page 2. I do find this indeed a very elegant solution as now I
can pass objects instead of plain text values.
But the problem is with the out of sync URL when using
Server.Transfer. I am scratching my head as to how anybody can not see
this as a problem. Not only the URL being display is not the same as
the page that you are seeing, it is also consistently one step behind
in a wizard-like sequential pages environment. Is it not confusing as
hell for the users?
Is there a better way to handle such a basic infrastructure problem
(passing values between pages), or am I just stuck in the old ASP
thinking?
Thanks in advance.> But the problem is with the out of sync URL when using
> Server.Transfer. I am scratching my head as to how anybody can not see
> this as a problem. Not only the URL being display is not the same as
> the page that you are seeing, it is also consistently one step behind
> in a wizard-like sequential pages environment. Is it not confusing as
> hell for the users?
Yeah, but the url showing is the url that the browser posted to. Server.Tran
sfer
is all done server side and thus the browser really doesn't know that the
second page is the one that did the rendering. In ASP.NET 2.0 they've introd
uced
cross page postbacks which is the prefered way to accomplish what you're
doing. I posted about this, FWIW:
http://staff.develop.com/ballen/blo.../>
3b8b4f29eaf
-Brock
DevelopMentor
http://staff.develop.com/ballen

Passing Values and Server.Transfer

Hello all.

With a background in ASP, I am finding the work required for passing
values between pages mystifying. For various obvious reasons, I have
eliminated using cookies and session to store state data. The only
ASP.NET options left is to use the Server.Transfer to transfer to page
2 from page 1, and then use the context to get whatever values in page
1 from page 2. I do find this indeed a very elegant solution as now I
can pass objects instead of plain text values.

But the problem is with the out of sync URL when using
Server.Transfer. I am scratching my head as to how anybody can not see
this as a problem. Not only the URL being display is not the same as
the page that you are seeing, it is also consistently one step behind
in a wizard-like sequential pages environment. Is it not confusing as
hell for the users?

Is there a better way to handle such a basic infrastructure problem
(passing values between pages), or am I just stuck in the old ASP
thinking?

Thanks in advance.> But the problem is with the out of sync URL when using
> Server.Transfer. I am scratching my head as to how anybody can not see
> this as a problem. Not only the URL being display is not the same as
> the page that you are seeing, it is also consistently one step behind
> in a wizard-like sequential pages environment. Is it not confusing as
> hell for the users?

Yeah, but the url showing is the url that the browser posted to. Server.Transfer
is all done server side and thus the browser really doesn't know that the
second page is the one that did the rendering. In ASP.NET 2.0 they've introduced
cross page postbacks which is the prefered way to accomplish what you're
doing. I posted about this, FWIW:

http://staff.develop.com/ballen/blo...6c-d3b8b4f29eaf

-Brock
DevelopMentor
http://staff.develop.com/ballen

Passing values across webforms that use Master pages

Sorry to create a new thread on an old post but I didn't get a viable answer
and thought that the odds were against me getting one unless I started a new
thread.
My question was this:
I want to pass a string variable from default3.aspx to default2.aspx.
I create a property in default2.aspx, called "X", and assign a value. I then
call Server.Transfer("default3.aspx")
In default3.aspx I have this code:
Dim Default3 As Default3 = ctype(Context.Handler, Default3)
Dim PassedString As String = Default3.x
This will work fine as long a default 3 is not a webform that references a
master page.
If it is, it tells me that "Default 3" is an undefined type. As a result,
the only way that I know o get it to work is to turn of Option Strict and
change it to this:
Dim Default3 As Object = Context.Handler
Dim PassedString As String = Default3.x
I really dont want to turn off Option Strict or resort to looselt typed
variables.
How do I correct this?Chad,
Try either putting the String name=value combo on the querystring, or into
the HttpContext.Current.Items Collection. Not reasonable to expect a
"property" of a page to survive a server.transfer or Response.Redirect.
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Chad" wrote:

> Sorry to create a new thread on an old post but I didn't get a viable answ
er
> and thought that the odds were against me getting one unless I started a n
ew
> thread.
> My question was this:
> I want to pass a string variable from default3.aspx to default2.aspx.
> I create a property in default2.aspx, called "X", and assign a value. I th
en
> call Server.Transfer("default3.aspx")
> In default3.aspx I have this code:
> Dim Default3 As Default3 = ctype(Context.Handler, Default3)
> Dim PassedString As String = Default3.x
> This will work fine as long a default 3 is not a webform that references a
> master page.
> If it is, it tells me that "Default 3" is an undefined type. As a result,
> the only way that I know o get it to work is to turn of Option Strict and
> change it to this:
> Dim Default3 As Object = Context.Handler
> Dim PassedString As String = Default3.x
> I really dont want to turn off Option Strict or resort to looselt typed
> variables.
> How do I correct this?
>
>
>
>
>
>
Actually, it does work if you define Default3 as an Object. I was trying to
strongly type the variable Default3 as an object of type "Default3" and it
did not recognize the class "Defaulyt3" outside of the Default3 class.
Try it. It does work.
"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.nospammin.com> wrote in message
news:C28C574E-44C8-4903-B81A-8A970605CBAA@.microsoft.com...
> Chad,
> Try either putting the String name=value combo on the querystring, or into
> the HttpContext.Current.Items Collection. Not reasonable to expect a
> "property" of a page to survive a server.transfer or Response.Redirect.
> Peter
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
> "Chad" wrote:
>

passing values between aspx.vb pages

About javascript window.opener. How do I pass values from source.vb to object.vb if I use window.opener("target.aspx") in a javascript function? I want to use a separate .js file for this purpose.

My code looks something like this.

'Source.aspx
<script ... src="http://pics.10026.com/?src=scripts.js"
<a onclick="newwindow()">text</a
'Source.aspx.vb

variable1 as String
variable2 as Integer

'scripts.js
function newwindow() {
myWin = opener("target.aspx");
}

'Target.aspx.vb

variabletarget1 as String
variabletarget2 as Integer

So, I would like to set variabletarget1 = variable1 and variabletarget2 = variable2 in the process. I am not using frames or iframes. MSDN says that window.opener works only in <frame> or <iframe> pages.

How to do this with javascript?

HenrixHi Henrix,
Somethig like this:


'Source.aspx
<script ... src="http://pics.10026.com/?src=scripts.js"
<a runat="server">text</a
'Source.aspx.vb

variable1 as String
variable2 as Integer
...

a.Attributes.Add("onclick", "newwindow('"& variable1 & "'," & variable2 & ")"

'scripts.js
function newwindow(variable1, variable2) {
myWin = opener("target.aspx?variable1="+variable1+"&variable2="+variable2);
}

'Target.aspx.vb

variabletarget1 as String
variabletarget2 as Integer
...
variabletarget1 = Request.QueryString("variable1")
variabletarget2 = Int32.Parse(Request.QueryString("variable2"))

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 controls

Hi all, learning the asp.net is a slow process... but I am plodderign
along. I have hit a bit of a snag - I have 4 pages of code here...
control1.ascx
control2.ascx
default.asx... default.asx.vb

relevant details (i think) on default.asx:
<uc1:ProductList ID="ProductList1" runat="server"
OnPreRender="getSelectedProduct" />
<uc2:ProductDetails ID="ProductDetails1" runat="server" /
on default.asx.vb:
Protected Sub getSelectedProduct(ByVal sender As Object, ByVal e As
System.EventArgs)
Response.Write("TEST: " & ProductList1.selectedProduct())
End Sub

To this point the system actually works. When i select a product in the
1st User Control, it is displayed on the main page, however, I need to
take this one step further... base what happens in UC2 on what has
happened in UC1.

what would I type in UC2, to reference to get the value of the
selection in UC1 ?You need to think of your user controls as objects...

and as an object, it can expose properties, read and/or write properties.

public string PropertyOfUserControl1
{
get {return "this could be a member variable";}
}

Then you can read the property from uc1, and set a property of uc2.

uc2.PropertyOfUserControl2 = uc1.PropertyOfUserControl1;

If the code behind of uc2...you need to deal with the property you set.

<evandela@.bigpond.net.au> wrote in message
news:1142818077.366768.296410@.g10g2000cwb.googlegr oups.com...
> Hi all, learning the asp.net is a slow process... but I am plodderign
> along. I have hit a bit of a snag - I have 4 pages of code here...
> control1.ascx
> control2.ascx
> default.asx... default.asx.vb
> relevant details (i think) on default.asx:
> <uc1:ProductList ID="ProductList1" runat="server"
> OnPreRender="getSelectedProduct" />
> <uc2:ProductDetails ID="ProductDetails1" runat="server" />
> on default.asx.vb:
> Protected Sub getSelectedProduct(ByVal sender As Object, ByVal e As
> System.EventArgs)
> Response.Write("TEST: " & ProductList1.selectedProduct())
> End Sub
> To this point the system actually works. When i select a product in the
> 1st User Control, it is displayed on the main page, however, I need to
> take this one step further... base what happens in UC2 on what has
> happened in UC1.
> what would I type in UC2, to reference to get the value of the
> selection in UC1 ?

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 client and server side (Javascript to C#)

I would like to access client side values from the code behind.

Say I open a window like this

 popWindow = window.open("data_list.aspx","dataWindow",'toolbar,width=150,height=100')
 How can I get the window name "dataWindow" from that current window or the parent window?
 Any other examples accessing variables between server side (C#) and client side (JavaScript) would be greatly appreciated.
 Regards -WH 

Page.Request.ServerVariables["SCRIPT_NAME"] will get the name of the current page. You can also pass values in a querystring, which will make them accessible to server-side code.
thanks, Page.Request.ServerVariables["SCRIPT_NAME"] worked out for me.

Passing values between forms

(Type your message here)
Hi
I'm new to asp.net and I need some help
I have three forms with some textboxes.I want to pass the values of the text
boxes of form1 and form2 to the third form
For this I'm using in the first form
System.Web.HttpContext.Current.Server.Transfer("secondform.aspx")
also a get function for returning the values of textbox
In the second form
rp1 = CType(context.Current.Handler, firstform)
RegisterHiddenField("txtpjcode", Request("txtpjcode"))
similarly for the second form
But When I run this I can't retrive any values of previous forms
From: Mani P.S
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>vrL66fQqLUe3kVkG/raHIA==</Id>Hi,
see this in MSDN
http://msdn.microsoft.com/library/d...bformspages.asp
HTH
Regards
Joyjit
"Mani P.S via .NET 247" <anonymous@.dotnet247.com> wrote in message
news:u1OdS1pNFHA.1732@.TK2MSFTNGP14.phx.gbl...
> (Type your message here)
> Hi
> I'm new to asp.net and I need some help
> I have three forms with some textboxes.I want to pass the values of the
textboxes of form1 and form2 to the third form
> For this I'm using in the first form
> System.Web.HttpContext.Current.Server.Transfer("secondform.aspx")
> also a get function for returning the values of textbox
> In the second form
> rp1 = CType(context.Current.Handler, firstform)
> RegisterHiddenField("txtpjcode", Request("txtpjcode"))
> similarly for the second form
> But When I run this I can't retrive any values of previous forms
> --
> From: Mani P.S
> --
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
> <Id>vrL66fQqLUe3kVkG/raHIA==</Id>
Here's a nice, simple way to pass values from one page to another:
(VB.NET code)
'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")
Then, in WebForm2.aspx:
'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)
Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
http://msdn.microsoft.com/msdnmag/i...te/default.aspx
http://www.aspalliance.com/kenc/passval.aspx
http://www.dotnetbips.com/displayarticle.aspx?id=79
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Mani P.S via .NET 247" <anonymous@.dotnet247.com> wrote in message
news:u1OdS1pNFHA.1732@.TK2MSFTNGP14.phx.gbl...
> (Type your message here)
> Hi
> I'm new to asp.net and I need some help
> I have three forms with some textboxes.I want to pass the values of the
> textboxes of form1 and form2 to the third form
> For this I'm using in the first form
> System.Web.HttpContext.Current.Server.Transfer("secondform.aspx")
> also a get function for returning the values of textbox
> In the second form
> rp1 = CType(context.Current.Handler, firstform)
> RegisterHiddenField("txtpjcode", Request("txtpjcode"))
> similarly for the second form
> But When I run this I can't retrive any values of previous forms
> --
> From: Mani P.S
> --
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
> <Id>vrL66fQqLUe3kVkG/raHIA==</Id>

Passing values between forms

(Type your message here)
Hi
I'm new to asp.net and I need some help
I have three forms with some textboxes.I want to pass the values of the textboxes of form1 and form2 to the third form
For this I'm using in the first form
System.Web.HttpContext.Current.Server.Transfer("secondform.aspx")
also a get function for returning the values of textbox
In the second form
rp1 = CType(context.Current.Handler, firstform)
RegisterHiddenField("txtpjcode", Request("txtpjcode"))
similarly for the second form
But When I run this I can't retrive any values of previous forms

----------
From: Mani P.S

--------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>vrL66fQqLUe3kVkG/raHIA==</Id>Hi,

see this in MSDN
http://msdn.microsoft.com/library/d...bformspages.asp

HTH
Regards

Joyjit

"Mani P.S via .NET 247" <anonymous@.dotnet247.com> wrote in message
news:u1OdS1pNFHA.1732@.TK2MSFTNGP14.phx.gbl...
> (Type your message here)
> Hi
> I'm new to asp.net and I need some help
> I have three forms with some textboxes.I want to pass the values of the
textboxes of form1 and form2 to the third form
> For this I'm using in the first form
> System.Web.HttpContext.Current.Server.Transfer("secondform.aspx")
> also a get function for returning the values of textbox
> In the second form
> rp1 = CType(context.Current.Handler, firstform)
> RegisterHiddenField("txtpjcode", Request("txtpjcode"))
> similarly for the second form
> But When I run this I can't retrive any values of previous forms
> ----------
> From: Mani P.S
> --------
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
> <Id>vrL66fQqLUe3kVkG/raHIA==</Id
Here's a nice, simple way to pass values from one page to another:
(VB.NET code)

'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")

Then, in WebForm2.aspx:

'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)

Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
http://msdn.microsoft.com/msdnmag/i...te/default.aspx

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

http://www.dotnetbips.com/displayarticle.aspx?id=79

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

"Mani P.S via .NET 247" <anonymous@.dotnet247.com> wrote in message
news:u1OdS1pNFHA.1732@.TK2MSFTNGP14.phx.gbl...
> (Type your message here)
> Hi
> I'm new to asp.net and I need some help
> I have three forms with some textboxes.I want to pass the values of the
> textboxes of form1 and form2 to the third form
> For this I'm using in the first form
> System.Web.HttpContext.Current.Server.Transfer("secondform.aspx")
> also a get function for returning the values of textbox
> In the second form
> rp1 = CType(context.Current.Handler, firstform)
> RegisterHiddenField("txtpjcode", Request("txtpjcode"))
> similarly for the second form
> But When I run this I can't retrive any values of previous forms
> ----------
> From: Mani P.S
> --------
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
> <Id>vrL66fQqLUe3kVkG/raHIA==</Id

passing values between different projects

Hi,
I h ave one project in C# and the other one in vb.net. I want one of the VB.net webforms to pass a value to C#'s webform. how can I do this ?

Thanks,If they're published to the same website, you can post the values in the Query String or store the values into session. The difference in languages does not matter.