Solved

ASP.NET url with Parameter

Posted on 2014-01-09
4
377 Views
Last Modified: 2014-01-09
I am new to creating dynamic websites using visual studio and vb.net.  My background is more in the use of Dreamweaver.  I have an aspx page which I want to add a link to another page including a parameter value.  On my code page I have the following:

'Declare variable
Dim strClient As String

'Page load
strClient = Request.QueryString("Client")

OK, now I want to add a link to the following url:
www.intranet.com/detail.asp?Client=[strClient]

What should I use to create this link and how should I go about it.  I'm sure this is probably very simple to do but I can't figure it out.  Hyperlink?  LinkButton?
0
Comment
Question by:schwientekd
  • 2
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 500 total points
ID: 39769031
If you do not need perform any processing on the server after the hyperlink / button is clicked, use the HyperLink control. It does not perform any postback. If you need to perform an action, such as update a database, then use the LinkButton.

For the HyperLink control, you can set the NavigateURL during the Page Load event so that it includes your parameter. You can also set it in the "HTML" page using the NavigateURL property using the <% %> tags.
0
 

Author Comment

by:schwientekd
ID: 39769091
OK, looks like I will use hyperlink for this.  I placed a Hyperlink control on the page and called it hrefClient.  In the Page Load event I added the line Me.hrefClient.NavigateUrl = "http://www.intranet.com/detail.asp?Client=1" (I left out the parameter to test this out first).

When I build the project it fails and gives the following error:
error BC30456: 'hrefClient' is not a member of 'Form1'

I believe this project was initially created in VS2005 and I am using VS2008, would that have something to do with the error message?  I don't understand why the control is not a member of the page it is on?  I'm very confused.
0
 

Author Comment

by:schwientekd
ID: 39769101
Wait, nevermind I just figured out what happened.  There was another page using the same code file.  I deleted the other page and the project builds now.
0
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 39769102
How did you add the control to the ASPX page? Did you drag and drop the control onto the page from the Toolbox or did you hand code the control onto the page?
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question