Onlineatoz.net | All posts tagged 'visualstudio toolbox control'

ToolBox HTML Control HTMLHidden

HTML Hidden Web Server Control

In ASP.NET environment,This article describes you how to work with HTML Hidden Control.In HTML environment, Hidden is an object that represents a Hidden control in an HTML form. The Hidden control in a HTML form contains all instance of an <input type="hidden"> tag.

The HtmlInputHidden control can be used to comprised information that is concealed from the user that means user unable to view the information. This information is sent when the Web page is posted back to the server.

There are several functions available to access the HTML Hidden.some of its funtions are as follows,

  • document.getElementById()
  • document.getElementByName()
Hidden Objects Properties
  • id -Sets or returns the id of a Hidden
  • form -Returns a reference to the form that contains the Hidden
  • alt -Sets or returns an alternate text to display if a browser does not support Hiddens
  • name -Sets or returns the name of a Hidden
  • type -Returns the type of form element a Hidden is
  • value -Sets or returns the text that is displayed on the Hidden
  • title -Sets or returns an element's advisory title
  • lang -Sets or returns the language code for an element
  • dir -Sets or returns the direction of text
  • className -Sets or returns the class attribute of an element
Hidden Objects Methods
  • blur() -Performs focus when leave from the control
  • click() -Simulates a mouse-click on a Hidden
  • focus() -Performs focus when enter into the control

The following code snippets explains you the HTML Hidden in the web form.

in .aspx.cs page,

void Page_Load(object sender, EventArgs e) 
      {

         if (Page.IsPostBack) 
         {
            Span1.InnerHtml="Hidden value: " + hid1.Value + "";
         }
      }

      void SubmitBtn_Click(object sender, EventArgs e) 
      {
         hid1.Value=StringContents.Value;
      }
        

in .aspx page,

 <form id="Form2" runat=server>
      <h3>HtmlInputHidden Sample</h3>
      <input id="hid1" 
             type=hidden 
             value="Initial Value" 
             runat=server>      
      <input id="StringContents" 
             type=text 
             size=40 
             runat=server>
      <p>
      <input id="Submit1" type=submit 
             value="Enter" 
             OnServerClick="SubmitBtn_Click" 
             runat=server>
      <p>
   </form>
 
Related Links

Posted by: Admin
Posted on: 9/18/2009 at 4:51 PM
Tags: , ,
Categories: Asp.net
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (2171) | Post RSSRSS comment feed

ToolBox Standard Control Table

Table,TableRow and TableCell Web Server Control

in ASP.NET environment,This article describes you how to work with Table,TableRow and TableCell Web Control.The table,TableRow and TableCell are similar to the HTML elements.The Table Web server control creates a general-purpose table on a Web Forms page.

Rows in the table are created as TableRow Web server controls, and cells within each row are implemented as TableCell Web server controls.

Web Server Table Vs Html Table
  • HTML table.enables you to create a static table in a web page by specify <table> element.you create HTML table when you are creating a static table (one in which you will not add or change content at run time), do not create a Table control.
  • a <HTMLTable> can became a Table control when including the runat=server property
  • Table that allows you to create and manipulate tables. for instance, adding rows or cells via server code.

The Table Web server control can be easier to program than the HtmlTable control because it offers an object model with typed properties that is consistent with other Web server controls. (The model is also consistent between the Table, TableRow, and TableCell controls.)

Web Server Table Vs Other List Web Server Controls
  • he list controls are data-bound. The list controls work only against a data source, whereas the Table control can display any combination of HTML text and controls, whether or not they are data-bound.
  • The list controls use templates to specify the layout of their elements. The Table control supports the TableCell child control, which you can fill as you would any HTML <td> element.
Binding Data to the Table Control

Although the Table control is not inherently data-bound, you can use it to display data from a database.you can bind any property of a Table control to a data source like as all other web control.

To Add Table Web Server Controls to a Page
  • Type <asp:Table></asp:Table> element in a Page
  • (or) From the Standard tab of the Toolbox, drag a Table control onto the page.
To add rows and cells to a Table Web server control at design time
  • Select the table, then open the Properties window and click the ellipsis button(..) for the Rows property.
  • Click Add to create a new row.
  • To add cells to the new row, make sure the row is selected in the Members list, and then click the ellipsis button (..) for the Cells property.
  • Click Add to create a new cell
To add rows and cells to a Table Web server control Programmatically,

the following code snippets demonstrates create rows and columns at run time.

in .aspx.cs page,

Protected void Button1_Click (object sender, System.EventArgs e)
{
   for(int i=1; i <= 3; i++) {
      // Create a new row and add it to the table.
      TableRow row1 = new TableRow();
      tbl1.Rows.Add(row1);
      for (int j = 1; j <= 9; j++) {
         // Create a new cell and add it to the row.
         TableCell cell1 = new TableCell();
         row1.Cells.Add(cell1);               
         // Mock up a product ID.
         string prodID = rowCtr + "_" + cellCtr;

         // Add a Label text as control.
         cell1.Controls.Add(new Label("Name: "));
         // Create a Hyperlink Web server control and add it to the cell.
         System.Web.UI.WebControls.HyperLink lnk = new HyperLink();
         lnk.Text = "welcome"+Convert.ToString(j);
         lnk.NavigateUrl = "http://www.yoursite.com/";
         cell1.Controls.Add(lnk);
      }
   }
}

              
 
Related Links

Posted by: Admin
Posted on: 9/11/2009 at 7:45 AM
Tags: , ,
Categories: Asp.net
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (1617) | Post RSSRSS comment feed