<asp:hyperlink> , Databinding

Discussion in 'ASP .Net' started by =?Utf-8?B?U2F0eWE=?=, Aug 11, 2005.

  1. Hi all,

    The following code is throwing a run time error "The server tag is not well
    formed.
    "

    <ItemTemplate>
    <asp:HyperLink Runat="server" ID="lnkFile"
    NavigateUrl="javascript:OpenImage('<%#
    DataBinder.Eval(Container.DataItem,"FileName") %>');"><%#
    DataBinder.Eval(Container.DataItem,"FileName") %></asp:HyperLink>
    </ItemTemplate>

    I am trying to open a file in new window. How can i acheive this?

    TIA
    Satya
    =?Utf-8?B?U2F0eWE=?=, Aug 11, 2005
    #1
    1. Advertising

  2. Try rewrite the code as follows:


    <asp:HyperLink Runat="server" ID="lnkFile"
    NavigateUrl='<%# "javascript:OpenImage('" +
    DataBinder.Eval(Container.DataItem,"FileName") + "');" %>'><%#
    DataBinder.Eval(Container.DataItem,"FileName") %></asp:HyperLink>

    HTH

    "Satya" <> wrote in message
    news:D...
    > Hi all,
    >
    > The following code is throwing a run time error "The server tag is not
    > well
    > formed.
    > "
    >
    > <ItemTemplate>
    > <asp:HyperLink Runat="server" ID="lnkFile"
    > NavigateUrl="javascript:OpenImage('<%# >
    > DataBinder.Eval(Container.DataItem,"FileName") %>');"><%# >
    > DataBinder.Eval(Container.DataItem,"FileName") %></asp:HyperLink>
    > </ItemTemplate>
    >
    > I am trying to open a file in new window. How can i acheive this?
    >
    > TIA
    > Satya
    Grant Merwitz, Aug 11, 2005
    #2
    1. Advertising

  3. Hi Grant,

    Thanks for the response.

    I tried with your code, but still it's not working.
    I am not even switch to design mode.

    I am posting the code for data grid and Page_load

    DataGrid:

    <asp:DataGrid id="dgImages" style="Z-INDEX: 101; LEFT: 53px; POSITION:
    absolute; TOP: 34px" runat="server"
    AutoGenerateColumns="False">
    <Columns>
    <asp:TemplateColumn HeaderText="File">
    <ItemTemplate>
    <asp:HyperLink Runat="server" ID="lnkFile" NavigateUrl='<%#
    "javascript:OpenImage('" + DataBinder.Eval(Container.DataItem,"FileUrl") +
    "');"%>'><%# DataBinder.Eval(Container.DataItem,"FileName")
    %></asp:HyperLink>

    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="File Type">
    <ItemTemplate>
    <asp:Label ID="Label2" Runat="server">
    <%# DataBinder.Eval(Container.DataItem,"FileType") %>
    </asp:Label>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="File Format">
    <ItemTemplate>
    <asp:Label ID="Label3" Runat="server">
    <%# DataBinder.Eval(Container.DataItem,"FileFormat") %>
    </asp:Label>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="UserUploaded">
    <ItemTemplate>
    <asp:Label ID="Label4" Runat="server">
    <%# DataBinder.Eval(Container.DataItem,"UserUploaded") %>
    </asp:Label>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="DateUploaded">
    <ItemTemplate>
    <asp:Label ID="Label1" Runat="server">
    <%# DataBinder.Eval(Container.DataItem,"DateUploaded") %>
    </asp:Label>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:DataGrid>


    page_load:


    private void Page_Load(object sender, System.EventArgs e)
    {
    DataTable dtFiles;
    DataRow drFile;
    dtFiles = new DataTable("Images");

    dtFiles.Columns.Add("FileName");
    dtFiles.Columns.Add("FileUrl");
    dtFiles.Columns.Add("FileType");
    dtFiles.Columns.Add("FileFormat");
    dtFiles.Columns.Add("Notes");
    dtFiles.Columns.Add("UserUploaded");
    dtFiles.Columns.Add("DateUploaded");

    drFile = dtFiles.NewRow();
    drFile["FileName"] = "Closings Title.pdf";
    drFile["FileUrl"] = @"http://cal2ac04/ustitle/Closings.pdf";
    drFile["FileType"] = "Closings";
    drFile["FileFormat"] = "PDF";
    drFile["Notes"] = "Closing note";
    drFile["UserUploaded"] = "XYZ";
    drFile["DateUploaded"] = "08/11/2005";
    dtFiles.Rows.Add(drFile);

    drFile = dtFiles.NewRow();
    drFile["FileName"] = "HUD.TIFF";
    drFile["FileUrl"] = @"http://cal2ac04/ustitle/HUD.TIFF";
    drFile["FileType"] = "HUD";
    drFile["FileFormat"] = "Image";
    drFile["Notes"] = "Hud Document";
    drFile["UserUploaded"] = "ABC";
    drFile["DateUploaded"] = "08/11/2005";
    dtFiles.Rows.Add(drFile);

    drFile = dtFiles.NewRow();
    drFile["FileName"] = "Buyer_Closing_Notice.doc";
    drFile["FileUrl"] = @"http://cal2ac04/ustitle/Buyer_Closing_Notice.doc";
    drFile["FileType"] = "Closings";
    drFile["FileFormat"] = "Doc";
    drFile["Notes"] = "Closing Notice to buyer";
    drFile["UserUploaded"] = "PQR";
    drFile["DateUploaded"] = "08/11/2005";
    dtFiles.Rows.Add(drFile);



    dgImages.DataSource = dtFiles;
    dgImages.DataBind();

    }




    --
    Satya Rao


    "Grant Merwitz" wrote:

    > Try rewrite the code as follows:
    >
    >
    > <asp:HyperLink Runat="server" ID="lnkFile"
    > NavigateUrl='<%# "javascript:OpenImage('" +
    > DataBinder.Eval(Container.DataItem,"FileName") + "');" %>'><%#
    > DataBinder.Eval(Container.DataItem,"FileName") %></asp:HyperLink>
    >
    > HTH
    >
    > "Satya" <> wrote in message
    > news:D...
    > > Hi all,
    > >
    > > The following code is throwing a run time error "The server tag is not
    > > well
    > > formed.
    > > "
    > >
    > > <ItemTemplate>
    > > <asp:HyperLink Runat="server" ID="lnkFile"
    > > NavigateUrl="javascript:OpenImage('<%# >
    > > DataBinder.Eval(Container.DataItem,"FileName") %>');"><%# >
    > > DataBinder.Eval(Container.DataItem,"FileName") %></asp:HyperLink>
    > > </ItemTemplate>
    > >
    > > I am trying to open a file in new window. How can i acheive this?
    > >
    > > TIA
    > > Satya

    >
    >
    >
    =?Utf-8?B?U2F0eWE=?=, Aug 11, 2005
    #3
  4. hmm, try adding Response.Write() in front of the strings

    <asp:HyperLink Runat="server" ID="lnkFile" NavigateUrl='<%#
    Response.Write("javascript:OpenImage('") +
    DataBinder.Eval(Container.DataItem,"FileUrl") + Response.Write("');")
    %>'><%# DataBinder.Eval(Container.DataItem,"FileName") %></asp:HyperLink>


    "Satya" <> wrote in message
    news:...
    > Hi Grant,
    >
    > Thanks for the response.
    >
    > I tried with your code, but still it's not working.
    > I am not even switch to design mode.
    >
    > I am posting the code for data grid and Page_load
    >
    > DataGrid:
    >
    > <asp:DataGrid id="dgImages" style="Z-INDEX: 101; LEFT: 53px; POSITION:
    > absolute; TOP: 34px" runat="server"
    > AutoGenerateColumns="False">
    > <Columns>
    > <asp:TemplateColumn HeaderText="File">
    > <ItemTemplate>
    > <asp:HyperLink Runat="server" ID="lnkFile" NavigateUrl='<%#
    > "javascript:OpenImage('" + DataBinder.Eval(Container.DataItem,"FileUrl")
    > +
    > "');"%>'><%# DataBinder.Eval(Container.DataItem,"FileName")
    > %></asp:HyperLink>
    >
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > <asp:TemplateColumn HeaderText="File Type">
    > <ItemTemplate>
    > <asp:Label ID="Label2" Runat="server">
    > <%# DataBinder.Eval(Container.DataItem,"FileType") %>
    > </asp:Label>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > <asp:TemplateColumn HeaderText="File Format">
    > <ItemTemplate>
    > <asp:Label ID="Label3" Runat="server">
    > <%# DataBinder.Eval(Container.DataItem,"FileFormat") %>
    > </asp:Label>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > <asp:TemplateColumn HeaderText="UserUploaded">
    > <ItemTemplate>
    > <asp:Label ID="Label4" Runat="server">
    > <%# DataBinder.Eval(Container.DataItem,"UserUploaded") %>
    > </asp:Label>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > <asp:TemplateColumn HeaderText="DateUploaded">
    > <ItemTemplate>
    > <asp:Label ID="Label1" Runat="server">
    > <%# DataBinder.Eval(Container.DataItem,"DateUploaded") %>
    > </asp:Label>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > </Columns>
    > </asp:DataGrid>
    >
    >
    > page_load:
    >
    >
    > private void Page_Load(object sender, System.EventArgs e)
    > {
    > DataTable dtFiles;
    > DataRow drFile;
    > dtFiles = new DataTable("Images");
    >
    > dtFiles.Columns.Add("FileName");
    > dtFiles.Columns.Add("FileUrl");
    > dtFiles.Columns.Add("FileType");
    > dtFiles.Columns.Add("FileFormat");
    > dtFiles.Columns.Add("Notes");
    > dtFiles.Columns.Add("UserUploaded");
    > dtFiles.Columns.Add("DateUploaded");
    >
    > drFile = dtFiles.NewRow();
    > drFile["FileName"] = "Closings Title.pdf";
    > drFile["FileUrl"] = @"http://cal2ac04/ustitle/Closings.pdf";
    > drFile["FileType"] = "Closings";
    > drFile["FileFormat"] = "PDF";
    > drFile["Notes"] = "Closing note";
    > drFile["UserUploaded"] = "XYZ";
    > drFile["DateUploaded"] = "08/11/2005";
    > dtFiles.Rows.Add(drFile);
    >
    > drFile = dtFiles.NewRow();
    > drFile["FileName"] = "HUD.TIFF";
    > drFile["FileUrl"] = @"http://cal2ac04/ustitle/HUD.TIFF";
    > drFile["FileType"] = "HUD";
    > drFile["FileFormat"] = "Image";
    > drFile["Notes"] = "Hud Document";
    > drFile["UserUploaded"] = "ABC";
    > drFile["DateUploaded"] = "08/11/2005";
    > dtFiles.Rows.Add(drFile);
    >
    > drFile = dtFiles.NewRow();
    > drFile["FileName"] = "Buyer_Closing_Notice.doc";
    > drFile["FileUrl"] = @"http://cal2ac04/ustitle/Buyer_Closing_Notice.doc";
    > drFile["FileType"] = "Closings";
    > drFile["FileFormat"] = "Doc";
    > drFile["Notes"] = "Closing Notice to buyer";
    > drFile["UserUploaded"] = "PQR";
    > drFile["DateUploaded"] = "08/11/2005";
    > dtFiles.Rows.Add(drFile);
    >
    >
    >
    > dgImages.DataSource = dtFiles;
    > dgImages.DataBind();
    >
    > }
    >
    >
    >
    >
    > --
    > Satya Rao
    >
    >
    > "Grant Merwitz" wrote:
    >
    >> Try rewrite the code as follows:
    >>
    >>
    >> <asp:HyperLink Runat="server" ID="lnkFile"
    >> NavigateUrl='<%# "javascript:OpenImage('" +
    >> DataBinder.Eval(Container.DataItem,"FileName") + "');" %>'><%#
    >> DataBinder.Eval(Container.DataItem,"FileName") %></asp:HyperLink>
    >>
    >> HTH
    >>
    >> "Satya" <> wrote in message
    >> news:D...
    >> > Hi all,
    >> >
    >> > The following code is throwing a run time error "The server tag is not
    >> > well
    >> > formed.
    >> > "
    >> >
    >> > <ItemTemplate>
    >> > <asp:HyperLink Runat="server" ID="lnkFile"
    >> > NavigateUrl="javascript:OpenImage('<%# >
    >> > DataBinder.Eval(Container.DataItem,"FileName") %>');"><%# >
    >> > DataBinder.Eval(Container.DataItem,"FileName") %></asp:HyperLink>
    >> > </ItemTemplate>
    >> >
    >> > I am trying to open a file in new window. How can i acheive this?
    >> >
    >> > TIA
    >> > Satya

    >>
    >>
    >>
    Grant Merwitz, Aug 11, 2005
    #4
  5. You should be carefull with the qoutes. Try

    <asp:HyperLink Runat="server" ID="lnkFile" NavigateUrl='<%#
    "javascript:OpenImage(\'" + DataBinder.Eval(Container.DataItem,"FileUrl") +
    "\');" %'><%# DataBinder.Eval(Container.DataItem,"FileName")
    %></asp:HyperLink>

    Eliyahu

    "Satya" <> wrote in message
    news:...
    > Hi Grant,
    >
    > Thanks for the response.
    >
    > I tried with your code, but still it's not working.
    > I am not even switch to design mode.
    >
    > I am posting the code for data grid and Page_load
    >
    > DataGrid:
    >
    > <asp:DataGrid id="dgImages" style="Z-INDEX: 101; LEFT: 53px; POSITION:
    > absolute; TOP: 34px" runat="server"
    > AutoGenerateColumns="False">
    > <Columns>
    > <asp:TemplateColumn HeaderText="File">
    > <ItemTemplate>
    > <asp:HyperLink Runat="server" ID="lnkFile" NavigateUrl='<%#
    > "javascript:OpenImage('" + DataBinder.Eval(Container.DataItem,"FileUrl")

    +
    > "');"%>'><%# DataBinder.Eval(Container.DataItem,"FileName")
    > %></asp:HyperLink>
    >
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > <asp:TemplateColumn HeaderText="File Type">
    > <ItemTemplate>
    > <asp:Label ID="Label2" Runat="server">
    > <%# DataBinder.Eval(Container.DataItem,"FileType") %>
    > </asp:Label>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > <asp:TemplateColumn HeaderText="File Format">
    > <ItemTemplate>
    > <asp:Label ID="Label3" Runat="server">
    > <%# DataBinder.Eval(Container.DataItem,"FileFormat") %>
    > </asp:Label>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > <asp:TemplateColumn HeaderText="UserUploaded">
    > <ItemTemplate>
    > <asp:Label ID="Label4" Runat="server">
    > <%# DataBinder.Eval(Container.DataItem,"UserUploaded") %>
    > </asp:Label>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > <asp:TemplateColumn HeaderText="DateUploaded">
    > <ItemTemplate>
    > <asp:Label ID="Label1" Runat="server">
    > <%# DataBinder.Eval(Container.DataItem,"DateUploaded") %>
    > </asp:Label>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > </Columns>
    > </asp:DataGrid>
    >
    >
    > page_load:
    >
    >
    > private void Page_Load(object sender, System.EventArgs e)
    > {
    > DataTable dtFiles;
    > DataRow drFile;
    > dtFiles = new DataTable("Images");
    >
    > dtFiles.Columns.Add("FileName");
    > dtFiles.Columns.Add("FileUrl");
    > dtFiles.Columns.Add("FileType");
    > dtFiles.Columns.Add("FileFormat");
    > dtFiles.Columns.Add("Notes");
    > dtFiles.Columns.Add("UserUploaded");
    > dtFiles.Columns.Add("DateUploaded");
    >
    > drFile = dtFiles.NewRow();
    > drFile["FileName"] = "Closings Title.pdf";
    > drFile["FileUrl"] = @"http://cal2ac04/ustitle/Closings.pdf";
    > drFile["FileType"] = "Closings";
    > drFile["FileFormat"] = "PDF";
    > drFile["Notes"] = "Closing note";
    > drFile["UserUploaded"] = "XYZ";
    > drFile["DateUploaded"] = "08/11/2005";
    > dtFiles.Rows.Add(drFile);
    >
    > drFile = dtFiles.NewRow();
    > drFile["FileName"] = "HUD.TIFF";
    > drFile["FileUrl"] = @"http://cal2ac04/ustitle/HUD.TIFF";
    > drFile["FileType"] = "HUD";
    > drFile["FileFormat"] = "Image";
    > drFile["Notes"] = "Hud Document";
    > drFile["UserUploaded"] = "ABC";
    > drFile["DateUploaded"] = "08/11/2005";
    > dtFiles.Rows.Add(drFile);
    >
    > drFile = dtFiles.NewRow();
    > drFile["FileName"] = "Buyer_Closing_Notice.doc";
    > drFile["FileUrl"] = @"http://cal2ac04/ustitle/Buyer_Closing_Notice.doc";
    > drFile["FileType"] = "Closings";
    > drFile["FileFormat"] = "Doc";
    > drFile["Notes"] = "Closing Notice to buyer";
    > drFile["UserUploaded"] = "PQR";
    > drFile["DateUploaded"] = "08/11/2005";
    > dtFiles.Rows.Add(drFile);
    >
    >
    >
    > dgImages.DataSource = dtFiles;
    > dgImages.DataBind();
    >
    > }
    >
    >
    >
    >
    > --
    > Satya Rao
    >
    >
    > "Grant Merwitz" wrote:
    >
    > > Try rewrite the code as follows:
    > >
    > >
    > > <asp:HyperLink Runat="server" ID="lnkFile"
    > > NavigateUrl='<%# "javascript:OpenImage('" +
    > > DataBinder.Eval(Container.DataItem,"FileName") + "');" %>'><%#
    > > DataBinder.Eval(Container.DataItem,"FileName") %></asp:HyperLink>
    > >
    > > HTH
    > >
    > > "Satya" <> wrote in message
    > > news:D...
    > > > Hi all,
    > > >
    > > > The following code is throwing a run time error "The server tag is not
    > > > well
    > > > formed.
    > > > "
    > > >
    > > > <ItemTemplate>
    > > > <asp:HyperLink Runat="server" ID="lnkFile"
    > > > NavigateUrl="javascript:OpenImage('<%# >
    > > > DataBinder.Eval(Container.DataItem,"FileName") %>');"><%# >
    > > > DataBinder.Eval(Container.DataItem,"FileName") %></asp:HyperLink>
    > > > </ItemTemplate>
    > > >
    > > > I am trying to open a file in new window. How can i acheive this?
    > > >
    > > > TIA
    > > > Satya

    > >
    > >
    > >
    Eliyahu Goldin, Aug 11, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. davetichenor
    Replies:
    1
    Views:
    810
    Eliyahu Goldin
    Oct 30, 2006
  2. jobs
    Replies:
    0
    Views:
    1,602
  3. Ken
    Replies:
    1
    Views:
    365
    Alvin Bruney
    Aug 16, 2003
  4. Earl Teigrob
    Replies:
    1
    Views:
    394
    Shravan
    Mar 1, 2004
  5. Dave
    Replies:
    0
    Views:
    928
Loading...

Share This Page