opening page in New Windowhttp://forums.asp.net/t/1798448.aspx/1?opening+page+in+New+WindowMon, 30 Apr 2012 13:53:03 -040017984484958127http://forums.asp.net/p/1798448/4958127.aspx/1?opening+page+in+New+Windowopening page in New Window <p>hi all</p> <p>i have a Link Buttons in&nbsp; GridView after clicking LB i need open Page in New Window i used</p> <pre class="prettyprint">protected void ViewInvoice(object sender, CommandEventArgs e) { int count=GvInvoice.Rows.Count; GridViewRow row = GvInvoice.Rows[1]; Label in_id=row.Cells[1].FindControl(&quot;lblInvoice&quot;) as Label; if(in_id!=null) { string invid=in_id.Text; string URL_Invoice= &quot;~/Invoices/&quot;&#43;invid&#43;&quot;.pdf?in_id={0}&quot;; Response.Redirect(string.Format(URL_Invoice, e.CommandArgument.ToString())); } }</pre> <p><br> <br> </p> <p></p> 2012-04-30T11:47:57-04:004958159http://forums.asp.net/p/1798448/4958159.aspx/1?Re+opening+page+in+New+WindowRe: opening page in New Window <p><br class="Apple-interchange-newline"> &nbsp;put the Script above of ur page .. and then call its Function into ur Button or linkButton &nbsp;into the 'onclientclick '.. etc example<br> <br> </p> <pre class="prettyprint">&lt;script type=&quot;text/javascript&quot;&gt; function PostToNewWindow() { originalTarget = document.forms[0].target; document.forms[0].target='_blank'; window.setTimeout(&quot;document.forms[0].target=originalTarget;&quot;,300); return true; } &lt;/script&gt; &lt;asp:LinkButton id=&quot;lbnkVidTtile1&quot; runat=&quot;Server&quot; OnClientClick=&quot;return PostToNewWindow();&quot; /&gt;</pre> <pre class="prettyprint"><br /><br /></pre> 2012-04-30T12:11:55-04:004958218http://forums.asp.net/p/1798448/4958218.aspx/1?Re+opening+page+in+New+WindowRe: opening page in New Window <p>hi</p> <p>thanks .. but my link buttons r within gridview .. im binding my GV on run time pls go through my code.. </p> 2012-04-30T12:38:59-04:004958222http://forums.asp.net/p/1798448/4958222.aspx/1?Re+opening+page+in+New+WindowRe: opening page in New Window <p>u welcome friend .. yeah i know that ur Linkbutton inside a Gridview ... that also works .. go to ASPX Page and Put the Script and Call it at ur Gridview's linkbutton event &quot;onclientclick &quot; as i explaned above&nbsp;<img src="http://forums.asp.net/scripts/tiny_mce/plugins/emotions/img/smiley-smile.gif" alt="Smile" title="Smile" border="0" class="emoticon">&nbsp;.</p> 2012-04-30T12:41:56-04:004958267http://forums.asp.net/p/1798448/4958267.aspx/1?Re+opening+page+in+New+WindowRe: opening page in New Window <p>Hi, Go through with this... hope u may solve</p> <pre class="prettyprint">&lt;script type=&quot;text/javascript&quot;&gt; function PostToNewWindow() { originalTarget = document.forms[0].target; document.forms[0].target='_blank'; window.setTimeout(&quot;document.forms[0].target=originalTarget;&quot;,300); return true; } &lt;/script&gt; &lt;asp:LinkButton id=&quot;lbnkVidTtile1&quot; runat=&quot;Server&quot; OnClientClick=&quot;return PostToNewWindow();&quot; /&gt;</pre> 2012-04-30T12:58:24-04:004958286http://forums.asp.net/p/1798448/4958286.aspx/1?Re+opening+page+in+New+WindowRe: opening page in New Window <p>i did it for u .. and here the &lt;Body&gt; tag .. with full code ...&nbsp;<br> <br> </p> <pre class="prettyprint">&lt;body&gt; &lt;script type=&quot;text/javascript&quot;&gt; function PostToNewWindow() { originalTarget = document.forms[0].target; document.forms[0].target = '_blank'; window.setTimeout(&quot;document.forms[0].target=originalTarget;&quot;, 300); return true; } &lt;/script&gt; &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt; &lt;div&gt; &lt;asp:GridView ID=&quot;GridView1&quot; runat=&quot;server&quot; AutoGenerateColumns=&quot;False&quot; DataSourceID=&quot;SqlDataSource1&quot; Width=&quot;181px&quot;&gt; &lt;Columns&gt; &lt;asp:BoundField DataField=&quot;user_name&quot; HeaderText=&quot;user_name&quot; SortExpression=&quot;user_name&quot; Visible=&quot;False&quot; /&gt; &lt;asp:BoundField DataField=&quot;arts&quot; HeaderText=&quot;arts&quot; SortExpression=&quot;arts&quot; /&gt; &lt;asp:BoundField DataField=&quot;egypt&quot; HeaderText=&quot;egypt&quot; SortExpression=&quot;egypt&quot; /&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:LinkButton ID=&quot;LinkButton1&quot; runat=&quot;server&quot; Text='&lt;%# Bind(&quot;user_name&quot;) %&gt;' OnClientClick=&quot;return PostToNewWindow();&quot;&gt;&lt;/asp:LinkButton&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;asp:SqlDataSource ID=&quot;SqlDataSource1&quot; runat=&quot;server&quot; ConnectionString=&quot;&lt;%$ ConnectionStrings: Choose You Connection String %&gt;&quot; SelectCommand=&quot;SELECT [user_name], [arts], [egypt] FROM [admins]&quot;&gt;&lt;/asp:SqlDataSource&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt;</pre> <p><br> &nbsp;</p> 2012-04-30T13:10:40-04:004958337http://forums.asp.net/p/1798448/4958337.aspx/1?Re+opening+page+in+New+WindowRe: opening page in New Window <p></p> <blockquote><span class="icon-blockquote"></span> <h4>narasappa</h4> <p></p> <p>hi</p> <p>thanks .. but my link buttons r within gridview .. im binding my GV on run time pls go through my code..</p> <p></p> </blockquote> <p></p> <p>The reason you might not think the posted solution will work is because link buttons are &quot;smoke and mirrors&quot;.&nbsp; It's not a &quot;normal&quot; link.&nbsp; When your page is rendered, the link simply calls javascript when clicked, and that javascript submits the form.&nbsp; Making the form submit to a new window will solve your issue.&nbsp; However you might have a problem if other controls on the page also submit (buttons etc) but you don't want those to open in a new window.</p> <p></p> 2012-04-30T13:53:03-04:00