Inline code prevents Design view

K

Ken McCrory

I have a page with some inline server-side code. An example line is:

<input type="hidden" name="fmFirstName" value="<%=Session("FirstName")%> ">

The code and logic works and does what it is supposed to do BUT if I try to
change from HTML view to Design view I get this error message:

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

How should I quote the value block so I can use Design view and still have
it work? Single quotes didn't work. Right now when I want to see design view
I comment out the lines with inline code.
 
C

Curt_C [MVP]

dont use the inline. Add a runat=server or use a server based control and
populate it from the codebehind.
 
B

bruce barker

in design view Session is null, so an error is thrown when it is accessed.
add a property accessor in the codebehind

string FirstName {
get {
if (Session != null)
return Session["FirstName"];
return "";
}
}

then in the aspx:

<input type="hidden" name="fmFirstName" value="<%=FirstName%> ">


| I have a page with some inline server-side code. An example line is:
|
| <input type="hidden" name="fmFirstName" value="<%=Session("FirstName")%>
">
|
| The code and logic works and does what it is supposed to do BUT if I try
to
| change from HTML view to Design view I get this error message:
|
| Could not open in Design view. Quote values differently inside a
| '<%..."value"...%>' block.
|
| How should I quote the value block so I can use Design view and still have
| it work? Single quotes didn't work. Right now when I want to see design
view
| I comment out the lines with inline code.
| --
| Ken "BiggMakk" McCrory
|
|
 
B

Brock Allen

Change to using single quotes:

<input type="hidden" name="fmFirstName" value='<%=Session("FirstName")%>'>
 
K

Ken McCrory

BINGO! We have a winner! The other two methods mentioned in other posts may
work and may even be the preferred way but this method was the quickest and
still works. Thanks Brock!
 

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

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top