Click here to Skip to main content
15,888,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
protected void Print_Data(object sender, EventArgs e)
   {
       string BK_Code = ((ImageButton)sender).CommandName;
       StringBuilder sb = new StringBuilder();
       sb.Append("<Script language='javascript'>");
       sb.Append("var m_Format = showModalDialog('Rpt_BL_Format.aspx','null','dialogHeight:150px,dialogWidth:150px,center:yes');");
       //StringBuilder sb1 = sb;
       //string ddl = sb.Append("m_Format").ToString();
       //sb.Append("if (m_Format == 'DL')");
      // sb.Append("window.open('Rpt_BL_DL.aspx?BK_Code=" + BK_Code + "&SMode=E','childwindow','fullscreen,status=yes, scrollbars=1,TOP=0,LEFT=0,resizable=YES');");
       sb.Append("if (m_Format == 'TTL')");
       sb.Append("window.open('Rpt_BL_BKN_TTL.aspx?BK_Code=" + BK_Code + "&SMode=E&m_Format=TTL','childwindow','fullscreen,status=yes, scrollbars=1,TOP=0,LEFT=0,resizable=YES');");
       sb.Append("</Script>");
       ClientScript.RegisterStartupScript(typeof(string), "Print", sb.ToString());
       sb.Append("if (m_Format == 'GBI')");
       sb.Append("window.open('Rpt_BL_BKN_GBI.aspx?BK_Code=" + BK_Code + "&SMode=E&m_Format=TTL','childwindow','fullscreen,status=yes, scrollbars=1,TOP=0,LEFT=0,resizable=YES');");
       sb.Append("</Script>");
       ClientScript.RegisterStartupScript(typeof(string), "Print", sb.ToString());
       sb.Append("if (m_Format == 'AIC')");
       sb.Append("window.open('Rpt_BL_BKN_AIC.aspx?BK_Code=" + BK_Code + "&SMode=E&m_Format=TTL','childwindow','fullscreen,status=yes, scrollbars=1,TOP=0,LEFT=0,resizable=YES');");
       sb.Append("</Script>");
       ClientScript.RegisterStartupScript(typeof(string), "Print", sb.ToString());
   }

the above code i have used to redirect and print the page. Here the first when m_Format == 'TTL' this only working, remaining GBI and AIC are not redirecting. This TTL, GBI and AIC are dropdownlist value
post solution for this
Thanks in advance
Posted
Updated 2-Jan-12 0:08am
v3

1 solution

Hi,

After your TTL code clear your StringBuilder and then again append all previous code and do for GBI and AIC.

Or you can create three individual StringBuilder and execute it.

correct me if this scenario doen't work for you,

Thanks
-amit.
 
Share this answer
 
Comments
AmitGajjar 2-Jan-12 6:50am    
in sb1 and sb2 you also need to add Script tags that you have added for sb.
rajrprk 2-Jan-12 6:58am    
i have created three string builder ie., SB,SB1,SB2
string BK_Code = ((ImageButton)sender).CommandName;
StringBuilder sb = new StringBuilder();
sb.Append("<Script language='javascript'>");
sb.Append("var m_Format = showModalDialog('Rpt_BL_Format.aspx','null','dialogHeight:150px,dialogWidth:150px,center:yes');");
sb.Append("if (m_Format == 'TTL')");
sb.Append("window.open('Rpt_BL_BKN_GBI.aspx?BK_Code=" + BK_Code + "&SMode=E&m_Format=TTL','childwindow','fullscreen,status=yes, scrollbars=1,TOP=0,LEFT=0,resizable=YES');");
sb.Append("</Script>");
ClientScript.RegisterStartupScript(typeof(string), "Print", sb.ToString());
StringBuilder sb1 = new StringBuilder();
sb1.Append("<Script language='javascript'>");
sb1.Append("var m_Format = showModalDialog('Rpt_BL_Format.aspx','null','dialogHeight:150px,dialogWidth:150px,center:yes');");
sb1.Append("if (m_Format == 'GBI')");
sb1.Append("window.open('Rpt_BL_BKN_GBI.aspx?BK_Code=" + BK_Code + "&SMode=E&m_Format=TTL','childwindow','fullscreen,status=yes, scrollbars=1,TOP=0,LEFT=0,resizable=YES');");
sb1.Append("</Script>");
ClientScript.RegisterStartupScript(typeof(string), "Print", sb1.ToString());
StringBuilder sb2 = new StringBuilder();
sb2.Append("<Script language='javascript'>");
sb2.Append("var m_Format = showModalDialog('Rpt_BL_Format.aspx','null','dialogHeight:150px,dialogWidth:150px,center:yes');");
sb2.Append("if (m_Format == 'AIC')");
sb2.Append("window.open('Rpt_BL_BKN_AIC.aspx?BK_Code=" + BK_Code + "&SMode=E&m_Format=TTL','childwindow','fullscreen,status=yes, scrollbars=1,TOP=0,LEFT=0,resizable=YES');");
sb2.Append("</Script>");
ClientScript.RegisterStartupScript(typeof(string), "Print", sb2.ToString());
But still not redirecting
AmitGajjar 2-Jan-12 7:05am    
using window.open you are opening page in same window that may cause problem, try to open in different window and check if it work. check open in new window

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900