Proper Way to add tbxXXX.Text to URL

  • Thread starter Thread starter Guest
  • Start date Start date
Herfried,

Thank you for your quick response. What would cause a textbox not to display
it's contents as the concatenated information. All I'm seeing is the URL
which is converted to a string and then = tbxLicense.Text and not the
contents of the textbox? HELP
--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
MS Authorized MAR
looking for used laptops for developmentally disabled.
 
Michael,
You need to build a string expression, it appears that you have a single
string.

Something like:


Dim url As String = _
"https://secure.plimus.com/jsp/validateKey.jsp?productId=" _
& tbxUser.text & "&key=" & tbxLicense.text & _
"&action=REGISTER--"

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


| Herfried,
|
| Thank you for your quick response. What would cause a textbox not to
display
| it's contents as the concatenated information. All I'm seeing is the URL
| which is converted to a string and then = tbxLicense.Text and not the
| contents of the textbox? HELP
| --
| Michael Bragg, President
| eSolTec, Inc.
| a 501(C)(3) organization
| MS Authorized MAR
| looking for used laptops for developmentally disabled.
|
|
| "Herfried K. Wagner [MVP]" wrote:
|
| > > What is the proper way to add textboxes to a URL so that the the text
is
| > > part of the URL? is it a "+" sign or the "&" ampersign?
| > >
| > >
https://secure.plimus.com/jsp/valid...er.text&key=tbxLicense.text&action=REGISTER--
| >
| > If the URL is stored as a string, you can use the '&' operator:
| >
| > \\\
| > Dim Url As String = ...
| > Url &= "bla"
| > ///
| >
| > --
| > M S Herfried K. Wagner
| > M V P <URL:http://dotnet.mvps.org/>
| > V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
| >
| >
 
Hello Michael,

If what you want is to embed some text string(get from a TextBox's Text
property) into an existing url string, you can use string concatenate like:

================
Dim url As String = "http://www.test.org/site1/default.aspx"
url = url & "?param1=" & TextBox1.Text
==================
#for VB.NET, you should use "&" char to concatenate string while in C#, you
should use "+"


You can also use String.Format method to create template based string text.
e.g.

========================
Dim urltmp As String =
"http://www.asp.net/default.aspx?param1={0}&param2={1}"
Dim url As String = String.Format(urltmp, TextBox1.Text, TextBox2.Text)
========================

In addition, if the text you want to append into url querystring will
contains some particular characters (such as "&", "+", or wide chars...), I
suggest you use HttpUtility.UrlEncode method to encode it before append
them into url.

#HttpUtility.UrlEncode Method
http://msdn2.microsoft.com/en-us/library/system.web.httputility.urlencode.as
px

e.g.

====================
Dim urltmp As String =
"http://www.asp.net/default.aspx?param1={0}&param2={1}"
Dim url As String = String.Format(urltmp,
HtmlUtility.UrlEncode(TextBox1.Text), HtmlUtility.UrlEncode(TextBox2.Text))
====================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top