Mark Zukerman Mark Zukerman - 16 days ago 6
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.

URL(whatever)

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

Example:

url(https://www.test.com/cgis/CGT/Reports/CGT_ID_Badge.asp?PersonID=2749)

Here is my code:

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


JavaScript:

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:

url(https://www.test.com/cgis/CGT/Reports/CGT_ID_Badge.asp?PersonID=2749)


How can I fix it?

Answer

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("https://www.test.com/cgis/{0}/Reports/CGT_ID_Badge.asp?PersonID={1}", m_User.CompanyCode, m_PersonID)