Mark Zukerman Mark Zukerman - 1 year ago 93
ASP.NET (C#) Question

Get only what inside of the String.Format

Here is my problem. I'm storing in a hidden field URL on the server side and when the user clicks on a button I'm reading the URL and opening up a pop up window. That thing is the string coming up.


How do I get rid of the "URL()" and only get what's inside of the string?



Here is my code:

Dim URL As String = Nothing
URL = String.Format("url({0}/Reports/CGT_ID_Badge.asp?PersonID={1})", m_User.CompanyCode, m_PersonID)
hfShipping.Value = URL


function PrintingReady(sender, args) {

var test = document.getElementById("<%=hfShipping.ClientID%>").value
$("#divLoadingMessage").css("display", "block");
var TryUrl = test;
printform(TryUrl); // Opening up a popup window with the URL
//__doPostBack("<%=btnPrintIDBadge.UniqueID %>", "");

This is what I'm getting:


How can I fix it?

Answer Source

Since you initializing the URL variable as a string you don't need to cast same as a URI which I think you were attempting to do.

All you need to do is:

string Url = String.Format("{0}/Reports/CGT_ID_Badge.asp?PersonID={1}", m_User.CompanyCode, m_PersonID)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download