geeta_tr

geeta_tr

  • NA
  • 6
  • 0

Counting total number of controls that are placed in a Asp.Net page

Aug 31 2005 4:35 AM
Hi,

i am new to this group. I am beginner in Asp.net. i started working on this following example.
1.i created one Asp.net web app in C#
2.And in the Design view i added a textbox,Button,and a label
3.and in the HTMl view i wrote the following code
<%@ Page language="c#" Codebehind="exercise.aspx.cs" AutoEventWireup="false" Inherits="WebApplication3.exercise" %><%@ Page language="c#" Codebehind="exercise.aspx.cs" AutoEventWireup="false" Inherits="WebApplication3.exercise" %>  <%@ Page language="c#" Codebehind="exercise.aspx.cs" AutoEventWireup="false" Inherits="WebApplication3.exercise" %>
<%@ Page language="c#" Codebehind="exercise.aspx.cs" AutoEventWireup="false" Inherits="WebApplication3.exercise" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 <HEAD>
  <title>exercise</title>
  <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
  <meta name="CODE_LANGUAGE" Content="C#">
  <meta name="vs_defaultClientScript" content="JavaScript">
  <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
 </HEAD>
 <body MS_POSITIONING="GridLayout">
  <form id="Form1" method="post" runat="server">
   <asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 176px; POSITION: absolute; TOP: 88px" runat="server"
    Width="168px" Height="72px"></asp:TextBox>
   <asp:HyperLink id="HyperLink1" style="Z-INDEX: 102; LEFT: 152px; POSITION: absolute; TOP: 208px"
    runat="server" Width="160px" Height="80px">HyperLink</asp:HyperLink>
   <asp:TextBox id="TextBox2" style="Z-INDEX: 103; LEFT: 376px; POSITION: absolute; TOP: 160px"
    runat="server" Width="176px" Height="112px"></asp:TextBox>
  </form>
  <%
    Response.Output.Write("Physical path of page is: {0}<br>",MapPath("exercise.aspx"));
    Response.Output.Write("Total no of controls: {0}<br>",Controls.Count);
    Response.Output.Write("The Value for IsPostBack is: {0}<br>",IsPostBack);
    Response.Output.Write("View State is: {0}<br>",EnableViewState==true?"Enabled":"Disabled");
    %>
 </body>
</HTML>

4. so for the Controls.Count the o/p should be 4(form+textbox+labelbox+button)
but the o/p what i am gettimng is 1


can anybody explain me which one is correct...
<% Response.Output.Write("Physical path of page is: {0}
",MapPath("exercise.aspx")); Response.Output.Write("Total no of controls: {0}
",Controls.Count); Response.Output.Write("The Value for IsPostBack is: {0}
",IsPostBack); Response.Output.Write("View State is: {0}
",EnableViewState==true?"Enabled":"Disabled"); %><% Response.Output.Write("Physical path of page is: {0}
",MapPath("exercise.aspx")); Response.Output.Write("Total no of controls: {0}
",Controls.Count); Response.Output.Write("The Value for IsPostBack is: {0}
",IsPostBack); Response.Output.Write("View State is: {0}
",EnableViewState==true?"Enabled":"Disabled"); %>