|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Datagrid window.openI am having trouble opening a new browser window without toolbars etc from a bound link in a datagrid. Basically my query string is an ID from the database which is connected to the URL. So far I have something like this: <a runat="server" onClick="window.open('<%# "../main/index.aspx?C=" + DataBinder.Eval Container.DataItem, "MyId")%', 'width=400,height=200,toolbar=no, menubar=no,scrollbars=yes)' ID="A2"> The message I'm receiving is : The server tag is not well formed If you could help me out I would be most grateful! Jack Hi Jack,
I'd use a little helper function to make the formatting easier. Here's some code that shows the idea. Let us know if it helps? Ken Microsoft MVP [ASP.NET] Toronto <asp:datagrid id="DataGrid1" runat="server" autogeneratecolumns="False" showheader="False"> <columns> <asp:templatecolumn> <itemtemplate> <asp:HyperLink ID="hlnk" onclick='<%#MakeHlnk(DataBinder.Eval(Container, "DataItem.myID")) %>' runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.myID") %>' NavigateUrl='<%#DataBinder.Eval(Container, "DataItem.myID") %>' > </asp:hyperlink> </itemtemplate> </asp:templatecolumn> </columns> </asp:datagrid> Private Sub Page_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load If Not IsPostBack Then DataGrid1.DataSource = CreateDataSource() DataGrid1.DataBind() End If End Sub Public Function MakeHlnk(ByVal strID As String) As String Dim strJS As String strJS = "javascript:window.open('index.aspx?C=" strJS = strJS & strID & "','_blank'," strJS = strJS & "'width=400,height=200,toolbar=no," strJS = strJS & "menubar=no,scrollbars=yes');return(false)" Return strJS End Function Function CreateDataSource() As DataTable Dim dt As New DataTable Dim dr As DataRow dt.Columns.Add(New DataColumn _ ("MyID", GetType(Int32))) dt.Columns.Add(New DataColumn _ ("StringValue", GetType(String))) dt.Columns.Add(New DataColumn _ ("CurrencyValue", GetType(Double))) dt.Columns.Add(New DataColumn _ ("Boolean", GetType(Boolean))) Dim i As Integer For i = 0 To 4 dr = dt.NewRow() dr(0) = i dr(1) = "Item " + i.ToString() dr(2) = 1.23 * (i + 1) dr(3) = (i = 4) dt.Rows.Add(dr) Next i Return dt End Function 'CreateDataSource Show quoteHide quote "Jack" <jac***@humlog.com> wrote in message news:6ea814a3.0503161439.1833d07e@posting.google.com... > Hi, > > I am having trouble opening a new browser window without toolbars etc > from a bound link in a datagrid. Basically my query string is an ID > from the database which is connected to the URL. > > So far I have something like this: > > <a runat="server" onClick="window.open('<%# "../main/index.aspx?C=" + > DataBinder.Eval Container.DataItem, "MyId")%', > 'width=400,height=200,toolbar=no, > menubar=no,scrollbars=yes)' ID="A2"> > > > The message I'm receiving is : The server tag is not well formed > > If you could help me out I would be most grateful! > > Jack Hi thanks for replying.
Should I be using a hyperlink or an anchor? hyperlink doesn't have the onclick event? did this work for you? Jack p.s. sorry for the delay in replying but I've been away. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! Hi Jack,
Yes, it works for me. Did you try my code? Show quoteHide quote "Jack Burton" <jac***@humlog.com> wrote in message news:u%23g8BFBMFHA.2464@TK2MSFTNGP10.phx.gbl... > Hi thanks for replying. > > Should I be using a hyperlink or an anchor? hyperlink doesn't have the > onclick event? did this work for you? All good - it works! I'm not sure what was going before.
Cheers, Jack *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
Datagrid postback problem?!?
Searched Datagrid with Paging? Using Server.Transfer with HyperLinkColumn in a datagrid Questions concerning detailsview or datagrid ASP.NET 2.0 Export to PDF How can I export a Dataview to Excel customising PagerStyle Showing x to y of z records Fonction de recherche dans un datagrid "Single record" edit control |
|||||||||||||||||||||||