Onlineatoz.net | September 2009

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 WepParts Control ImportCatalogPart

ImportCatalogPart Web Server Control

in ASP.NET environment,This article describes you how to work with ImportCatalogPart Web Control.The goal of the ImportCatalogPart Web server control is to imports a description file for a WebPart control or any other server control.

By using ImportCatalogPart control,an user can add a control at the runtime into the web page. The description file enables users to share settings for WebPart controls.It is an XML file that that contains name/value pairs which describes the state of the control.After imports a description file, the WebPart control referenced in the file appears within the ImportCatalogPart control and a user can add the control to the page.

ImportCatalogPart control using with Web Parts controls

It can be compiled into an assembly or it can be a .ascx file for these purposes . In either case, the control must be referenced in an imported description file that exist on the Web server containing the hosting page.The ImportCatalogPart control can only at visible stage When a user switches the page to catalog display mode.

For exporting a Description file for a control, which meets the following,

  • The control has properties marked with the Personalizable attribute.
  • The Web.config file has the enableExport attribute value set to true in the element.
  • You have set the value of the ExportMode property on the control to a value other than the default value of None, which prohibits export.
Setting an ImportCatalogPart Web Server Control

For displaying an ImportCatalogPart Web server control run time , It requires a Web Parts page is in edit mode, and when the user has selected an associated WebPart control for editing.

the following code snippets demonstrates how to work with the ImportCatalogPart Control

in .aspx.cs page,

protected void Button1_Click(object sender, EventArgs e)
  {
    wp1.DisplayMode = WebPartManager.BrowseDisplayMode;
  }

  protected void Button2_Click(object sender, EventArgs e)
  {
    wp1.DisplayMode = WebPartManager.CatalogDisplayMode;
  }

  protected void Page_Load(object sender, EventArgs e)
  {
    Label1.Text = "Scope is: "
      + wp1.Personalization.Scope.ToString();
  }

        

in .aspx page,

<html  >
<head id="head1" runat="server">
    <title>Example</title>
</head>
<body>
    <form id="form2" runat="server">
    <div>
      <asp:WebPartManager ID="wp1" runat="server">
        <Personalization InitialScope="Shared" Enabled="True" />
      </asp:WebPartManager>

      <asp:WebPartZone ID="WebPartZone1" runat="server" 
        EmptyZoneText="No parts to show.">
        <ZoneTemplate>
        </ZoneTemplate>
        <CloseVerb Text="Close This Part" />
        <MinimizeVerb Text="Minimize This Part" />
        <EditVerb Text="Edit This Part" />
      </asp:WebPartZone>

      <asp:CatalogZone ID="CatalogZone1" runat="server" >
        <ZoneTemplate>
          <asp:PageCatalogPart ID="PageCatalogPart1" runat="server" />
          <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" 
            runat="server">
            <WebPartsTemplate>
              <asp:Calendar id="Calendar1" runat="server" /> 
              <asp:CreateUserWizard ID="CreateUserWizard1" 
                runat="server" />
            </WebPartsTemplate>
          </asp:DeclarativeCatalogPart>
          <asp:ImportCatalogPart ID="ImportCatalogPart1" runat="server"/>
        </ZoneTemplate>
      </asp:CatalogZone>

      <hr />
      <asp:Button ID="Button1" runat="server" 
        Text="Browse Mode" OnClick="Button1_Click" />
      <asp:Button ID="Button2" runat="server" 
        Text="Catalog Mode" OnClick="Button2_Click" /><br />
      <asp:Label ID="Label1" runat="server" Text="" />
    </div>
    </form>
</body>
</html>                    
                    
 
Related Links

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