<form runat="server"> automatically adds <div> tag to code contained within. Is there a way to stop


M

mark4asp

<form runat="server"> automatically adds <div> tag to code contained
within. Is there a way to stop that?

Mixing block-level elements with inline-level elements messes up the
HTML becasuse that is invalid for a strict implementation. <span> is
in-line-level and <div> is block-level. I don't want to mix up <span>
and <div>

I'm using an <asp:Button> here because when it switches to the URL I
need to check that the user is in the correct role - their role
determines which page they go to. Perhaps there's a better way to do
that?, which allows me to avoid using a form and a postback here?

Here is my server-side code:

<tr>
<td colspan="3">
<a href="../Search/Search.aspx"><span class="MenuButtonLeft"
id="cmdSearch" onmouseover="MenuButtonIn(this);"
onmouseout="MenuButtonOut(this);">Search and Data Download</span></a>
<span class="MenuSpacerLeft"></span>
<form id="Form1" runat="server"><asp:Button
ID="cmdPensionwatch" runat="server" Text="PensionWatch"
CssClass="MenuButtonLeft2" OnCommand="cmdPensionwatch_Command" /></
form>
<span class="MenuSpacerLeft"></span>
<a href="../DealFlow/DealFlow.aspx"><span
class="MenuButtonLeft" id="cmdDealFlow"
onmouseover="MenuButtonIn(this);" onmouseout="MenuButtonOut(this);"
Deal Flow</span></a>
<span class="MenuSpacerLeft"></span>
<span></span>
<a href="javascript:downloadSummaryPDF('M');"><span
class="MenuButtonRight" id="cmd4Week"
onmouseover="MenuButtonIn(this);" onmouseout="MenuButtonOut(this);" >4
week Summary</span></a>
<span class="MenuSpacerRight"></span>
<a href="javascript:downloadSummaryPDF('F');"><span
class="MenuButtonRight" id="cmd2Week"
onmouseover="MenuButtonIn(this);" onmouseout="MenuButtonOut(this);" >2
week Summary</span></a>
<span class="MenuSpacerRight"></span>
<a href="javascript:downloadSummaryPDF('W');"><span
class="MenuButtonRight" id="cmd1Week"
onmouseover="MenuButtonIn(this);" onmouseout="MenuButtonOut(this);" >1
week Summary</span></a>
<span class="MenuSpacerRight"></span>
</td>
</tr>


This is my HTML. Notice how the inline <span> and block-level <div>
are mixed up - ouch!


<tr>
<td colspan="3">
<a href="../Search/Search.aspx"><span class="MenuButtonLeft"
id="cmdSearch" onmouseover="MenuButtonIn(this);"
onmouseout="MenuButtonOut(this);">Search and Data Download</span></a>
<span class="MenuSpacerLeft"></span>
<form name="Form1" method="post" action="News.aspx"
id="Form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="...blah...blah..." />
</div>
<input type="submit" name="cmdPensionwatch" value="PensionWatch"
id="cmdPensionwatch" class="MenuButtonLeft2"
onmouseover="MenuButtonIn(this);" onmouseout="MenuButtonOut(this);" />
<div>

<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
value="...blah...blah..." />
</div></form>
<span class="MenuSpacerLeft"></span>
<a href="../DealFlow/DealFlow.aspx"><span
class="MenuButtonLeft" id="cmdDealFlow"
onmouseover="MenuButtonIn(this);" onmouseout="MenuButtonOut(this);"
Deal Flow</span></a>
<span class="MenuSpacerLeft"></span>
<span></span>
<a href="javascript:downloadSummaryPDF('M');"><span
class="MenuButtonRight" id="cmd4Week"
onmouseover="MenuButtonIn(this);" onmouseout="MenuButtonOut(this);" >4
week Summary</span></a>
<span class="MenuSpacerRight"></span>
<a href="javascript:downloadSummaryPDF('F');"><span
class="MenuButtonRight" id="cmd2Week"
onmouseover="MenuButtonIn(this);" onmouseout="MenuButtonOut(this);" >2
week Summary</span></a>
<span class="MenuSpacerRight"></span>
<a href="javascript:downloadSummaryPDF('W');"><span
class="MenuButtonRight" id="cmd1Week"
onmouseover="MenuButtonIn(this);" onmouseout="MenuButtonOut(this);" >1
week Summary</span></a>
<span class="MenuSpacerRight"></span>
</td>
</tr>
 
Ad

Advertisements

?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

mark4asp said:
<form runat="server"> automatically adds <div> tag to code contained
within. Is there a way to stop that?

Mixing block-level elements with inline-level elements messes up the
HTML becasuse that is invalid for a strict implementation. <span> is
in-line-level and <div> is block-level. I don't want to mix up <span>
and <div>

I'm using an <asp:Button> here because when it switches to the URL I
need to check that the user is in the correct role - their role
determines which page they go to. Perhaps there's a better way to do
that?, which allows me to avoid using a form and a postback here?

You can't have inline elements directly inside the form tag, so you need
that div tag.
 

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

Top