Basic understanding about the div tag

T

Tony Johansson

<%@ Page Language="C#" %>

Hello!

I must say I have been using C# for 1.5 years but asp.net is new to me.
I have not been using html much either.

Below is a simple aspx page below.
I wonder in the code-behind there is a div tag where the two asp.net control
is placed in.

I can for example move this row
<asp:Label ID=lblMyLabel runat=server />
after the div tag
I can also remove the div tag completely.

I both cases there is no visual difference when I run this aspx page
So I wonder can somebody tell me some basic understanding about how to use
this div tag


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

protected void btnMyButton_Click(object sender, EventArgs e)
{
lblMyLabel.Text = "Någon <b>klickade</b> på knappen!";
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<H3>Ett enkelt webbformulärexempel</H3>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnMyButton" runat="server"
OnClick="btnMyButton_Click" Text="Min knapp" /><br />
<asp:Label ID=lblMyLabel runat=server />
</div>
</form>
</body>
</html>

//Tony
 
A

Andrew Morton

Tony said:
Below is a simple aspx page below.
I wonder in the code-behind there is a div tag where the two asp.net
control is placed in.

I can for example move this row
<asp:Label ID=lblMyLabel runat=server />
after the div tag
I can also remove the div tag completely.

I both cases there is no visual difference when I run this aspx page
So I wonder can somebody tell me some basic understanding about how
to use this div tag

What are you trying to achieve?

A <div> tag would typically be styled using CSS; various tutorials are
available, e.g.

http://www.w3schools.com/css/default.asp

Look at the page source in your browser to see how ASP.NET renders the
controls.

(Also, you will be better off putting your code in a code-behind page.)

HTH,

Andrew
 

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