Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > <asp:hyperlink> , Databinding

Reply
Thread Tools

<asp:hyperlink> , Databinding

 
 
=?Utf-8?B?U2F0eWE=?=
Guest
Posts: n/a
 
      08-11-2005
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
 
Reply With Quote
 
 
 
 
Grant Merwitz
Guest
Posts: n/a
 
      08-11-2005
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" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
=?Utf-8?B?U2F0eWE=?=
Guest
Posts: n/a
 
      08-11-2005
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:

<aspataGrid 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>
</aspataGrid>


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" <(E-Mail Removed)> wrote in message
> news(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
Grant Merwitz
Guest
Posts: n/a
 
      08-11-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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:
>
> <aspataGrid 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>
> </aspataGrid>
>
>
> 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" <(E-Mail Removed)> wrote in message
>> news(E-Mail Removed)...
>> > 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

>>
>>
>>



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      08-11-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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:
>
> <aspataGrid 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>
> </aspataGrid>
>
>
> 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" <(E-Mail Removed)> wrote in message
> > news(E-Mail Removed)...
> > > 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

> >
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Databinding expressions are only supported on objects that have a DataBinding event jobs ASP .Net 0 09-25-2007 11:54 PM
Gridview encoding, or how to run commands before gridview's default databinding, or, how do I disable default databinding at all? Sergei Shelukhin ASP .Net 1 11-12-2006 01:43 PM
ComboBox design-time DataBinding setting questions. dbuchanan ASP .Net 3 02-01-2006 12:15 PM
DataGrid Custom Column Error when DataBinding "does not contain a definition for 'DataBinding'" Earl Teigrob ASP .Net Datagrid Control 1 03-01-2004 04:52 AM
is databinding in asp.net read-only? neil m ASP .Net 3 06-27-2003 11:48 PM



Advertisments