I am trying to pass information through a URL. I have seen a VB example like
<a href="http://links.10026.com/?link=details.aspx?id={0}", Container.DataItem("EmployeeID"
Is the {0} supposed to be a placeholder or something?
Then in C#, i tried to just go something like
<a href='details.aspx?id=<%#DataBinder.Eval(Container.DataItem, "author_ID") %>'><%#DataBinder.Eval(Container.DataItem, "au_lname")%></a><br /
And it works like it should..
Does anyone have a reference of how to properly pass variables through a URL like this?
Or.. what is the proper name of this?
ThanksI am not sure exactly what you are looking for. This is the most basic way of passing variables to a web page. It is based on the GET method which appends the variable id and value to the URL string. There are a number of security issues with this method, as the variable values in plain text and viewable to the user and the amount of data that can be sent is restricted by the maximum allowed length of the URL string, usually 256 chars. However it's simplicity usually makes it useable in some situations.
The other method to pass variables to a web page is through the POST method. This is more secure and more information can be passed.
Hmm.. well thanks for the security warning but, still how would you do this? Security is not an issue at this point for this.
With C#, are you supposed to use a ?id={0} thing, or just skip the {0}, what is that even doing in VB.NET?
Thanks
Oh I see what you are asking now. Basically there is no correct way to build up the URL string, you can concatenate strings or even use a StringBuilder. As long as you build a URL string that is valid.
In the VB example the {0} is indeed a place holder that is replaced by the variable positioned after the ",". In your case the value of Container.DataItem("EmployeeID" ).
In C# I think you can use the {0} thing as well or you could use any of the other string concatenation symbols like the overloaded + operator.
A valid URL string is of the form:
[the URL] ie the webpage that you want to go to
? this indicates that GET variables are about to follow
name1 the name of the first variable
= equals
value1 the value of the first variable
& indicates the start of another variable
name2
=
value2
and so on.
Ah.. thanks
Is there some advantage in using the {0} over just leaving it out?