Monday, March 26, 2012

pass the control value from one web form to another form

Hi Experts,

I want to pass the selectedDate value from my calender
form to another web form or a web user control. Could you
please show me how to do this?

Thanks in advance.Tom,

There are a number of choices to do so.

Depending on your needs, you could use Server.Transfer or Response.Redirect
and the query string.

To use the query string

Response.Redirect("pagetwo.aspx?date=" & selectedDate.ToString)

Then on page two:

Dim Date As Date = CType(Request.Querystring.Item("date"), Date)

If you want to use Server.Transfer (Which would be more suited if a number
of variables need to be passed to the second page.) I suggest reading up on
it a bit more. It's fairly easy to do, but can be confusing for the user
because they are moved to page two but their browser's address bar will
still display the first page's url.

If you want some quick code samples I have some in the code library of my
web site: www.aboutfortunate.com. Just use the search box in the code
library area and input: "Server.Transfer".

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche

"tom" <anonymous@.discussions.microsoft.com> wrote in message
news:00d201c3a947$75660be0$a401280a@.phx.gbl...
> Hi Experts,
> I want to pass the selectedDate value from my calender
> form to another web form or a web user control. Could you
> please show me how to do this?
> Thanks in advance.
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.dotnetjunkies.com/tutori...?tutorialid=600

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

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"tom" <anonymous@.discussions.microsoft.com> wrote in message
news:00d201c3a947$75660be0$a401280a@.phx.gbl...
> Hi Experts,
> I want to pass the selectedDate value from my calender
> form to another web form or a web user control. Could you
> please show me how to do this?
> Thanks in advance.
Hi Steve and S. Justin,

Thank you very much for your responses. I'm sorry that I
didn't explain my problem more clearly on my previous
mail. My problem is a different situation. On my page one
there is textbox and the page two only contains a calendar
control. I need to open page one first and click a button
on page one will open the page two. After user selected a
date from the calendar the page two will close and the
date should be shown on the page one's textbox. I'm
struggling with how to pass value back to page one when
the page one is already opened and update page one's data?

Please help me!
Thanks in advance.

>--Original Message--
>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.../04/ASPNETUserS
tate/default.aspx
>http://www.aspalliance.com/kenc/passval.aspx
>http://www.dotnetjunkies.com/tutori...?tutorialid=600
>http://www.dotnetbips.com/displayarticle.aspx?id=79
>--
>I hope this helps,
>Steve C. Orr, MCSD, MVP
>http://Steve.Orr.net
>Hire top-notch developers at http://www.able-
consulting.com
>
>"tom" <anonymous@.discussions.microsoft.com> wrote in
message
>news:00d201c3a947$75660be0$a401280a@.phx.gbl...
>> Hi Experts,
>>
>> I want to pass the selectedDate value from my calender
>> form to another web form or a web user control. Could
you
>> please show me how to do this?
>>
>> Thanks in advance.
>>
>
>.
Tom,

I think this article is just what you need:

http://www.vb2themax.com/Item.asp?PageID=TipBank&ID=614

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche

"tom" <anonymous@.discussions.microsoft.com> wrote in message
news:0e5401c3a9ee$cd69a7f0$a301280a@.phx.gbl...
> Hi Steve and S. Justin,
> Thank you very much for your responses. I'm sorry that I
> didn't explain my problem more clearly on my previous
> mail. My problem is a different situation. On my page one
> there is textbox and the page two only contains a calendar
> control. I need to open page one first and click a button
> on page one will open the page two. After user selected a
> date from the calendar the page two will close and the
> date should be shown on the page one's textbox. I'm
> struggling with how to pass value back to page one when
> the page one is already opened and update page one's data?
> Please help me!
> Thanks in advance.
> >--Original Message--
> >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.../04/ASPNETUserS
> tate/default.aspx
> >http://www.aspalliance.com/kenc/passval.aspx
> >http://www.dotnetjunkies.com/tutori...?tutorialid=600
> >http://www.dotnetbips.com/displayarticle.aspx?id=79
> >--
> >I hope this helps,
> >Steve C. Orr, MCSD, MVP
> >http://Steve.Orr.net
> >Hire top-notch developers at http://www.able-
> consulting.com
> >"tom" <anonymous@.discussions.microsoft.com> wrote in
> message
> >news:00d201c3a947$75660be0$a401280a@.phx.gbl...
> >> Hi Experts,
> >>
> >> I want to pass the selectedDate value from my calender
> >> form to another web form or a web user control. Could
> you
> >> please show me how to do this?
> >>
> >> Thanks in advance.
> >>
> >.

0 comments:

Post a Comment