Open new page
-
how do we open new aspx page or html file in new window from within a function in the .cs file. (note: i have the html code that i want it in the page in a string variable) more explaination: i have a function that render the forms in my page into an html code, this is to open in it in a new page to be printable version. my current code now open the new page in the same page, and this is the code: HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(strHTML); HttpContext.Current.Response.End(); where strHtml is the variable that contains the html code of the new page. thanks in advance
-
how do we open new aspx page or html file in new window from within a function in the .cs file. (note: i have the html code that i want it in the page in a string variable) more explaination: i have a function that render the forms in my page into an html code, this is to open in it in a new page to be printable version. my current code now open the new page in the same page, and this is the code: HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(strHTML); HttpContext.Current.Response.End(); where strHtml is the variable that contains the html code of the new page. thanks in advance
You cant directly from the code behind as the server doesnt have access to the clients pc, but if you use Page.RegisterStartupScript(.NET 1.1) or ClientScript.RegisterStartupScript(for .net3.5) or RegisterClientScriptBlock you can use javascript to open the new page, with the html contents. you'll have to enclose the js function in a block for it to work right. The difference between the functions is when they get executed. i cant remember the perticulars right now, i havnt used them in a while..i typically use StartupScript. A quick MSDN search should explain the differences rather easily. and if you want this to happen each time a button or some other control fires an event just use <your control="">.attributs.add(event, js code); Hope i helped. </your>