problem with quotes in vs.net

  • Thread starter Thread starter Henry Tam
  • Start date Start date
H

Henry Tam

I have this piece of code that give me problem in vs.net html design
mode.

<A href="javascript:launchMeterDlg('<%=Me.bid%>','<%#
DataBinder.Eval(Container, "DataItem.MeterID") %>')">

while this work prefectly well when I tested. How i can make this work
in design mode as well?

Thanks
 
Henry

Unfortunately Design view does not handle well nested double quotes, even if
you put them inside single quotes. Try to write the same code differently,
avoiding quote nesting.

Thanks
Mikhail Arkhipov (MSFT)
 
Hi h_tam,

Thank you for using Microsoft Newsgroup Service. As for the question you
mentioned, here is my suggestion:
In case that you want to use some quote ("") in the <%# %> bound, you
should use ' to
include the <%# %> rather than use ", For example:
<ItemTemplate>

<asp:HyperLink NavigateUrl='<%# "target.aspx?id="
+DataBinder.Eval(Container.DataItem,"id")%>' runat="server"
ID="lnkNav">view</asp:HyperLink>

</ItemTemplate>

But be careful that don't include other text in the '' beside the <%# %>,
such as:

<asp:HyperLink NavigateUrl='other text<%# "target.aspx?id="
+DataBinder.Eval(Container.DataItem,"id")%>' runat="server"
ID="lnkNav">view</asp:HyperLink>

That'll cause all the expression between '' be analyzed as a normal string.
The <%# ........%> bound will be output as plain text.

In addition, if your expression is too complex which contains more than two
hierarchy of quote, I think there does exist some limit on analysis the
quotes for VS.NET IDE.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
THANKS! It work very well. I have been thinking too much. It is much
easier than I thought.

Here is the modification to my orginal piece:

<A href='<%# "javascript:launchMeterDlg(""" + Me.bid +""","""+
DataBinder.Eval(Container, "DataItem.MeterID").ToString() +""")" %>'>

btw. I am also impress with your support response time.

Thanks again.

Henry
 
Hi h_tam,

Congratulations! I'm glad that my suggestion has worked for you. Also,
thanks for your support!
 
Back
Top