Could not open Design view. Quote values differently in a '<%..."values"...%>' block.

R

Rob Meade

Hi all,

I am getting the above error when I try to flick from HTML to Design view in
Visual Studio - I get the jist of the error message, and I know the line of
code which it refers to which is this;

<asp:TemplateColumn>

<ItemTemplate>

<a class="normalText" href="javascript:void(0);"
onclick="populateForm('<%=Request.QueryString("controlid") %>', '<%#
DataBinder.Eval(Container.DataItem, "CrfExpansion") %> ','<%=("hid" &
Right(Request.QueryString("controlid"),
Len(Request.QueryString("controlid"))-3)) & "Code"%>', '<%#
DataBinder.Eval(Container.DataItem, "CrfDHANationalCode") %>');">Select</a>

</ItemTemplate>

</asp:TemplateColumn>


As you can see theres a good mixture of crap in there! It's the onClick
event that I believe is the problem - which reads:

onclick="populateForm
(
'<%=Request.QueryString("controlid") %>',
'<%# DataBinder.Eval(Container.DataItem, "CrfExpansion") %> ',
'<%=("hid" & Right(Request.QueryString("controlid"),
Len(Request.QueryString("controlid"))-3)) & "Code"%>',
'<%# DataBinder.Eval(Container.DataItem, "CrfDHANationalCode") %>'
)

if we break it open...Can anyone suggest how this might be changed to allow
me to flick back and forth again, I had assumed that I would need the single
quotes ( ' ) around the values that I'm sending the javascript function,
incase for example there was a comma ( , ) in the values coming through (for
whatever reason), and I'm used to having double quotes ( " ) in syntax such
as Request.QueryString("blah")

Whats most annoying is that until I flick back to Design view it wont add
any of the server controls I've typed in manually (well copied and pasted
and renamed) to the code behind view - and I dont fancy typing that little
lot in! :eek:)

Any suggestions appreciated.

Regards

Rob
 
C

Cowboy \(Gregory A. Beamer\) [MVP]

I would consider building the entire anchor by writing out a literal and
binding it to the form. For example, you can stick a panel on the page and
bind the literals there (LiteralControl). Your biggest issue here is double
quotes within single quotes within double quotes. The whole thing can be
built behind the scenes. To break it out, you end up with something like:

//C# version
StringBuilder sb = new StringBuilder();
sb.Append("<a class=\"normalText\" href=\"javascript:void(0);\" ");
sb.Append("onclick=\"populateForm('"+Request.QueryString("controlid")+"',
");
//etc.

LiteralControl lc = new LiteralControl(sb.ToString());
Panel1.Controls.Add(lc);

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
R

Rob Meade

...
I would consider building the entire anchor by writing out a literal and
binding it to the form. For example, you can stick a panel on the page and
bind the literals there (LiteralControl). Your biggest issue here is double
quotes within single quotes within double quotes. The whole thing can be
built behind the scenes. To break it out, you end up with something like:

//C# version
StringBuilder sb = new StringBuilder();
sb.Append("<a class=\"normalText\" href=\"javascript:void(0);\" ");
sb.Append("onclick=\"populateForm('"+Request.QueryString("controlid")+"',
");
//etc.

LiteralControl lc = new LiteralControl(sb.ToString());
Panel1.Controls.Add(lc);

Hi Gregory,

Many thanks for your informative reply - I now have it working -yay! :)

Regards

Rob
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top