Jump to content

Problem With A <%# ... %> Tag?


cyber0ne
 Share

Recommended Posts

I'm using Visual Studio to make a page for my website and the following line in my HTML code is giving me trouble (sorry for any wrapping):<a href='<%# "java script:PreviewPicture('" + DataBinder.Eval(Container.DataItem, "Preview") + "', '" + DataBinder.Eval(Container.DataItem, "Photo") + "');" %>'>The error I get is that, when I try to switch to Design View in Visual Studio, it tells me that I need to quote values differently in a <% ... %> block. Any idea what I'm doing wrong?-cyber0nehttp://www.cyber0ne.com

Link to comment
Share on other sites

It is a bug in visual studio...you have done nothing wrong.If you use (") inside <%= %> you get this error. Try changing (") to (') if you can.you may have to resort to commenting out that bit of code each time you need to switch to design view.I know it is annoying but it is fixed in VS.Net 2005.

Link to comment
Share on other sites

  • 3 weeks later...

U can use like this<a href="<%# 'java script:PreviewPicture('" + DataBinder.Eval(Container.DataItem, "Preview") + "', '" + DataBinder.Eval(Container.DataItem, "Photo") + "');' %>">May be ur problem will be solved .u can aloso use Function like:This is good : Because Some browser Doesn't Support javascript. So instead of that below is more fair.----At HTML Side:<a href='<%#FetchScript(DataBinder.Eval(Container.DataItem, "Preview"), DataBinder.Eval(Container.DataItem, "Photo"))%>'>At Code Side:Public function FetchScript(byval strPrv as string, byval strPhoto as string) as string{dim strReturn as stringstrReturn = "java script:PreviewPicture('" & strPrv & "','" & strPhoto & "');"return strReturn}

Link to comment
Share on other sites

This is good : Because Some browser Doesn't Support javascript. So instead of that below is more fair.
You just say that your solution doesn't use javascriptthen....
At HTML Side:<a href='<%#FetchScript(DataBinder.Eval(Container.DataItem, "Preview"), DataBinder.Eval(Container.DataItem, "Photo"))%>'>At Code Side:Public function FetchScript(byval strPrv as string, byval strPhoto as string) as string{dim strReturn as stringstrReturn = "java script:PreviewPicture('" & strPrv & "','" & strPhoto & "');"return strReturn}
boom...javascript...how is that better then calling the javascript directly????
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...