How to open a pop up window on clicking hyperlinkfield inside gridview
-
How to open a pop up window on clicking hyperlinkfield inside gridview,also i have to pass to querystrings to the second page. <asp:HyperLinkField HeaderText="View Resume" Text="View" Target="_blank" DataNavigateUrlFields="cand_id,rrf_id" DataNavigateUrlFormatString="ResumeDetails.aspx?cand_id={0}&rrf_id={1}" > </asp:HyperLinkField> thnx for ny reply.. MiThuN NaRaYaNaN
-
How to open a pop up window on clicking hyperlinkfield inside gridview,also i have to pass to querystrings to the second page. <asp:HyperLinkField HeaderText="View Resume" Text="View" Target="_blank" DataNavigateUrlFields="cand_id,rrf_id" DataNavigateUrlFormatString="ResumeDetails.aspx?cand_id={0}&rrf_id={1}" > </asp:HyperLinkField> thnx for ny reply.. MiThuN NaRaYaNaN
mithun narayanan wrote:
How to open a pop up window on clicking hyperlinkfield inside gridview
On RowDataBound event of gridview, find the hyperlink button and add Onclick attributes there.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
-
mithun narayanan wrote:
How to open a pop up window on clicking hyperlinkfield inside gridview
On RowDataBound event of gridview, find the hyperlink button and add Onclick attributes there.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
thanx navaneeth.... But still prblm.. i have already tried with row command,but its not entering inside this function i tried putting break points.also thers no command name for hyperlink fields.also ia am not using hperlink buttons am using hyperlink field Mithun Narayanan
modified on Tuesday, December 18, 2007 6:39:43 AM
-
How to open a pop up window on clicking hyperlinkfield inside gridview,also i have to pass to querystrings to the second page. <asp:HyperLinkField HeaderText="View Resume" Text="View" Target="_blank" DataNavigateUrlFields="cand_id,rrf_id" DataNavigateUrlFormatString="ResumeDetails.aspx?cand_id={0}&rrf_id={1}" > </asp:HyperLinkField> thnx for ny reply.. MiThuN NaRaYaNaN
First you need an Itemplate in the GridView with Hyperlink as one of the required columns. I think you already have that. Then implement the row data bound event as below: protected void GridView_RowDataBound ( object sender, GridViewRowEventArgs e ) { LinkButton lnkBut = new LinkButton(); HyperLink hlnk = new HyperLink(); if ( (ListItemType)e.Row.RowType == ListItemType.Item || (ListItemType)e.Row.RowType == ListItemType.AlternatingItem ) { hlnk = (HyperLink)( e.Row.FindControl("HyperLink1") ); string strPathFromDB = hlnk.Text; //NOTE: OR this can be a predetermined path hard-coded here if you wish to have the same path for all rows. You can add your query string after the path. hlnk.NavigateUrl = String.Format("{0}", strPathFromDB.Replace("\\", "/")); hlnk.Target = "_blank"; ALTERNATE WAY: Attach javascript to Hyperlink. url = "DocumentLinkControl.aspx?TradeDate=" + tradeDate + "&CounterParty=" + counterParty lnkBut.Attributes.Add("onclick", "window.open('" + url + "',null,'left=400, top=50, height=800, width= 650, status=no, resizable= no, scrollbars= yes, toolbar= no,location= no, menubar= no');"); } } Let me know if this didnt work..
Pankaj Chamria, Software Programmer.
-
thanx navaneeth.... But still prblm.. i have already tried with row command,but its not entering inside this function i tried putting break points.also thers no command name for hyperlink fields.also ia am not using hperlink buttons am using hyperlink field Mithun Narayanan
modified on Tuesday, December 18, 2007 6:39:43 AM
mithun narayanan wrote:
ia am not using hperlink buttons am using hyperlink field
Have you tried in Control collection ?
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
-
mithun narayanan wrote:
ia am not using hperlink buttons am using hyperlink field
Have you tried in Control collection ?
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
thnks Navneeth,that still not workd., i ve found alternate way for that <asp:TemplateField HeaderText="View Resume"> <ItemTemplate> <asp:Hyperlink Text="View" ID="Hyperlink2" NavigateUrl=<%#"javascript:my_window=window.open('ResumeDetails.aspx?cand_id=" + DataBinder.Eval(Container.DataItem,"cand_id").ToString() + "&rrf_id=" + DataBinder.Eval(Container.DataItem,"rrf_id").ToString() + "','my_window','toolbar=no, location=no, titlebar=no, linkbar=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=800, height=600, copyhistory=no');my_window.focus()" %> Runat="Server"> </asp:Hyperlink> </ItemTemplate> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField>
-
First you need an Itemplate in the GridView with Hyperlink as one of the required columns. I think you already have that. Then implement the row data bound event as below: protected void GridView_RowDataBound ( object sender, GridViewRowEventArgs e ) { LinkButton lnkBut = new LinkButton(); HyperLink hlnk = new HyperLink(); if ( (ListItemType)e.Row.RowType == ListItemType.Item || (ListItemType)e.Row.RowType == ListItemType.AlternatingItem ) { hlnk = (HyperLink)( e.Row.FindControl("HyperLink1") ); string strPathFromDB = hlnk.Text; //NOTE: OR this can be a predetermined path hard-coded here if you wish to have the same path for all rows. You can add your query string after the path. hlnk.NavigateUrl = String.Format("{0}", strPathFromDB.Replace("\\", "/")); hlnk.Target = "_blank"; ALTERNATE WAY: Attach javascript to Hyperlink. url = "DocumentLinkControl.aspx?TradeDate=" + tradeDate + "&CounterParty=" + counterParty lnkBut.Attributes.Add("onclick", "window.open('" + url + "',null,'left=400, top=50, height=800, width= 650, status=no, resizable= no, scrollbars= yes, toolbar= no,location= no, menubar= no');"); } } Let me know if this didnt work..
Pankaj Chamria, Software Programmer.
thnks Pankaj,that still not workd., i ve found alternate way for that <asp:TemplateField HeaderText="View Resume"> <ItemTemplate> <asp:Hyperlink Text="View" ID="Hyperlink2" NavigateUrl=<%#"javascript:my_window=window.open('ResumeDetails.aspx?cand_id=" + DataBinder.Eval(Container.DataItem,"cand_id").ToString() + "&rrf_id=" + DataBinder.Eval(Container.DataItem,"rrf_id").ToString() + "','my_window','toolbar=no, location=no, titlebar=no, linkbar=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=800, height=600, copyhistory=no');my_window.focus()" %> Runat="Server"> </asp:Hyperlink> </ItemTemplate> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField>