newbie question - opening one webform from another and passimg parammeters

B

Bogdan Zamfir

Hi,

I'm new to ASP.NET, and I'm trying to get started with.
I have a webform with a drop down list of clients (from an Access database).
Also I have a buton Edit.

Autopostback prop for dropdown list is set to true, and when user select a
client from the list, below the list I display details about that client (I
have a BO who handle the client retrival, based on selection from the list).

What I want now is when user click Edit button, to open another web form to
edit client's data.

My questions are:
1. How can I direct user to another web form when Edit buton is clicked?
2. How can I pass the client ID (which I can retrive from the drop-down
list) from webform 1 to webform 2? In general, how can I make the edit
webform to be able to get some data from first webform?

Thank you.
Bogdan Zamfir
 
S

S. Justin Gengo

Bogdan,

There are a number of ways to do what you ask.

In the button click event use any one of the following:
1) Response.Redirect("page2.aspx?valuetopass=1")

in this case you would use a query string to pass values to the next
page:

on page two: Request.QueryString("valuetopass") to get the value

2) Set a context object:

Context("valuetopass") = 1

Use Server.Transfer to go to the next page.

Server.Transfer("page2.aspx")


There are more complex things you can do with server.transfer. I'm not
showing how to get the value back out of the context object because you'll
need to look at the other details about server.transfer anyway. I have some
sample code on how to use Server.Transfer in the code library on my site:
www.aboutfortunate.com. Just search for: "use server.transfer" or something
similar.

Sincerely,

Justin
--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
B

Bogdan Zamfir

Hi,

Thank you very much for your detailed explanation.
However I have one more question, related to my first post.

I remember I saw somewhere, but I'm not able to find it again, how to pass a
reference from first page tp second one, so second page was able to access
all public properties and objects form first page.

How can I accomplish this?
This was my first thought on passing ClientID to second page (actually I
thought I can make second page to actually retrive ClientID directly from a
public property of first page).

Thank you.

Bogdan
 
S

S. Justin Gengo

Bogdan,

Check out the Server.Transfer sample on my site. That's exactly what it is
about.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
M

MS News \(MS ILM\)

Justin, explain YOUR code below please??
What is you want other members from the page.
do you call this member function from the second page and what do you pass
as ContextTransferred
What the Replace doing here?


Public Class GetTransferredContextPageName
Public Function GetPageName(ByVal ContextTransferred As
System.Web.HttpContext) As String
Try
Dim Page As Object = ContextTransferred.Handler
Dim PageName As String = LCase(Page.GetType.ToString)
PageName = Replace(PageName, "_aspx", "")
PageName = Replace(PageName, "asp.", "")
Return PageName
Catch e As Exception
Throw e
End Try
End Function
End Class
 
M

MS News \(MS ILM\)

Justin,
Thank you for taking the time. Well done.
I will try it and If I have any Question you will know.
Thanks again.
 
M

MS News \(MS ILM\)

Justin,

From time to time when I don't get my .NETBeer I tend to forget.
We all need some extra sleep.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top