HELP!!!!!!! ASP.NET C# code behind pop up.
-
private void EnterTIR( string myMSEL, int myPTNumber, int myEntryOrder, int myPTSUBNr ) { string url = "../TCAIMS/Forms/NewTir.aspx?MSEL='"+ myMSEL.ToString() +"'&PTNumber=" + myPTNumber.ToString()+"&EntryOrder="+ myEntryOrder.ToString()+"&PTSUBNr="+ myPTSUBNr.ToString()+"&UID='"+LoginID.Text+"'"; // string windowName = "NewTir"; string openParams = "width=700,height=800,toolbar=1,resizable=1"; StringBuilder sb = new StringBuilder(); sb.Append("" + Environment.NewLine); sb.Append("window.open('" + url + "', '" + windowName + "','" + openParams + "');"); sb.Append(""); Page.RegisterStartupScript("openWindowScript", sb.ToString()); }
It just wont open my window, the debugger steps through it all. -
private void EnterTIR( string myMSEL, int myPTNumber, int myEntryOrder, int myPTSUBNr ) { string url = "../TCAIMS/Forms/NewTir.aspx?MSEL='"+ myMSEL.ToString() +"'&PTNumber=" + myPTNumber.ToString()+"&EntryOrder="+ myEntryOrder.ToString()+"&PTSUBNr="+ myPTSUBNr.ToString()+"&UID='"+LoginID.Text+"'"; // string windowName = "NewTir"; string openParams = "width=700,height=800,toolbar=1,resizable=1"; StringBuilder sb = new StringBuilder(); sb.Append("" + Environment.NewLine); sb.Append("window.open('" + url + "', '" + windowName + "','" + openParams + "');"); sb.Append(""); Page.RegisterStartupScript("openWindowScript", sb.ToString()); }
It just wont open my window, the debugger steps through it all. -
private void EnterTIR( string myMSEL, int myPTNumber, int myEntryOrder, int myPTSUBNr ) { string url = "../TCAIMS/Forms/NewTir.aspx?MSEL='"+ myMSEL.ToString() +"'&PTNumber=" + myPTNumber.ToString()+"&EntryOrder="+ myEntryOrder.ToString()+"&PTSUBNr="+ myPTSUBNr.ToString()+"&UID='"+LoginID.Text+"'"; // string windowName = "NewTir"; string openParams = "width=700,height=800,toolbar=1,resizable=1"; StringBuilder sb = new StringBuilder(); sb.Append("" + Environment.NewLine); sb.Append("window.open('" + url + "', '" + windowName + "','" + openParams + "');"); sb.Append(""); Page.RegisterStartupScript("openWindowScript", sb.ToString()); }
It just wont open my window, the debugger steps through it all.Do you really want the apostrophes around the values in the query string? They will end up as part of the value when you read the values from the query string. If any of the values in the query string may contain any characters that has a special mening in an url, they have to be url encoded (using the Server.UrlEncode method). If you really want the apostrophes in the values, you have to encode them as \' when putting the url in the Javascript string, otherwise the first apostrophe in the url will end the string. And on a side note: Why on earth are you using string concatenation when you have a StringBuilder? Use the Append method to add each string to the StringBuilder instead of first concatenating strings and then adding them.
sb.AppendLine("");
sb.AppendLine("window.open('").Append(url).Append("','").Append(windowName).Append("','" ).Append(openParams).Append("');");
sb.Append("");--- single minded; short sighted; long gone;
-
Do you really want the apostrophes around the values in the query string? They will end up as part of the value when you read the values from the query string. If any of the values in the query string may contain any characters that has a special mening in an url, they have to be url encoded (using the Server.UrlEncode method). If you really want the apostrophes in the values, you have to encode them as \' when putting the url in the Javascript string, otherwise the first apostrophe in the url will end the string. And on a side note: Why on earth are you using string concatenation when you have a StringBuilder? Use the Append method to add each string to the StringBuilder instead of first concatenating strings and then adding them.
sb.AppendLine("");
sb.AppendLine("window.open('").Append(url).Append("','").Append(windowName).Append("','" ).Append(openParams).Append("');");
sb.Append("");--- single minded; short sighted; long gone;
-
Ibuprofen wrote:
I did use string bulider.
Yes, but you used string concatenation to create strings to add to the StringBuilder. There is no reason to create the intermittent strings as you can add each string directly to the StringBuilder.
Ibuprofen wrote:
Do I need to use string bulider to bulid the url string?
You don't have to use a StringBuilder at all if you don't want to.
--- single minded; short sighted; long gone;
-
Ibuprofen wrote:
I did use string bulider.
Yes, but you used string concatenation to create strings to add to the StringBuilder. There is no reason to create the intermittent strings as you can add each string directly to the StringBuilder.
Ibuprofen wrote:
Do I need to use string bulider to bulid the url string?
You don't have to use a StringBuilder at all if you don't want to.
--- single minded; short sighted; long gone;
-
Guffa, as I test this, I will let you know if it works. I just wanted to say Thank you, you are the first person to ever give me a decent response on code project.