Pass information from winform to webform to display info on webform.

Is there a way in visual basic .net to pass information from a windows form to a webform when a user clicks a button on the winform. I need to send the correct data to the webform to display information that pertains to the winform. I appreciate any help in this matter, thanks.

Mike
xrosemAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ptakjaCommented:
Do you want to populate fields on a web form, or click a button on the WinForm and have the browser open up to a specific page where you can extract data?

IF the latter, you can use QueryStrings to pass the info:

In your WINFORM app when the button is clicked:

Dim URL as string = String.Format("http://www.mywebsite.com/MyPage.aspx?Data1={0}&Data2={1}", 190, "catalog")
Process.Start(URL)  'Kick off default browser to URL listed.

In this example, your default browser would open to the page specified.

Then in your WebForm page named "MyPage.aspx" you would have some code to pull the QueryString data:

Data1 = 190
Data2 = "catalog"

from this then you can fill fields on the form, or perform db lookups, etc...
0
xrosemAuthor Commented:
I would like the winform to popluate the webform fields.
0
xrosemAuthor Commented:
On the later part where you click a button on the winform how does that code give the webform the information.

Dim URL as string = String.Format("http://www.mywebsite.com/MyPage.aspx?Data1={0}&Data2={1}", 190, "catalog")
Process.Start(URL)  'Kick off default browser to URL listed.

Is data1 and data2 string variables and they get passed? Then you reference the variables on the webform when it is open?
 
I appreciate your help.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

xrosemAuthor Commented:
It states that process is not declared. What  do i need to declare it as to get the page to fire? Or what is the process.start?
0
ptakjaCommented:
Data1 & Data2 are called "Query Strings". They get passed to the web app via the URL. In my example, URL would look like this after the String.Format is done:

URL ==> "http://www.mywebsite.com/MyPage.aspx?Data1=190&Data2=catalog"


You can use the QueryString method of the Request object to pull the name/value pairs off the URL.

Request.QueryString("<var name>")

All values are returned as strings. So if you have numeric data, you need to covert them to the appropriate type

Using the data from my original example:

Dim intData1 As Integer = Convert.ToInt32(Request.QueryString("Data1"))   'Cast data as integer
Dim strData2 As String = Request.QueryString("Data2")

Data1 & Data2 are arbitrary names. You can name them anything you want. And you can have as many querystring arguments as you like within the limits of the URL length (which I think is 1024 chars). Just make sure each name/value pair is separated from the next by the "&" symbol.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ptakjaCommented:
Sorry...the Process object is part of System.Diagnostics

So either add "Imports System.Diagnostics" outside your class or explicitly call it out as:

System.Diagnostics.Process.Start(blah blah)
0
ptakjaCommented:
The "?" after the page name tells the the URL parser that there are query strings in the URL. That is what populates the Request Object's Querystring collection.
0
xrosemAuthor Commented:
ptakja, thanks it worked great. You are truly awsome!!! Thanks a bunch.

Mike
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.