ASP.NET Code
  Home arrow ASP.NET Code arrow Page 3 - User Controls and Client Side Scripting
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET CODE

User Controls and Client Side Scripting
By: JB Reddy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 92
    2004-02-18

    Table of Contents:
  • User Controls and Client Side Scripting
  • Starting Our User Control
  • Utilizing the UserControls

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    User Controls and Client Side Scripting - Utilizing the UserControls


    (Page 3 of 3 )

    While utilizing the user controls in a web form it must be registered in the form at declaration section. For example, if our control file is named as “MyScriptControl.Ascx”, it must be registered using this control: 


    <%@ Page Language="Vb"  %>
    <%@ Register TagPrefix="MyUserCtl" TagName="MyTag" src="MyScriptControl.Ascx" %>

    Each server control has “<Asp:” prefix at declaration. For user controls, we have to define our prefix. For our control we use TagPrefix  “MyUserCtl”.  Tagname is the reference of the control instance in the form and the source of the user control. Src is the source file which contains the code for the user control.

    When time comes to use the user control declare a tag by using the following familiar format:


    <MyUserCtl:MyTag Id="MyTagCtl" runat="Server" />

    We can add attributes according to the requirement (example:  ViewState=”true”). As we discussed earlier we can add the Javascript in the Aspx page for the actions of the controls which are placed in the user control. We must remember that the TagId used in this declaration is the prefix which we applied to the controls id in the user control (I.e.  'MyTagCtl_MyText). To avoid this complex naming mechanism we can use “this” also.

    Run the aspx form and click on the checkbox and on textbox to see controls in action. Congratulations, we now have our first user control!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    ASP.NET CODE ARTICLES

    - How to Use the ListBox Control in ASP.NET 2.0
    - How to Load XML Documents in ASP.NET 2.0
    - DataGrid Code
    - ASP.NET Guestbook
    - User Controls and Client Side Scripting
    - ASP.NET Programming with Microsoft's AS...
    - ASP.NET Basics (part 3): Hard Choices
    - ASP.NET Basics (part 2): Not My Type
    - ASP.NET Basics (part 1): Nothing But .Net
    - Directory Tree Browser
    - How to get the confirmation of Yes/No from a...
    - Complete example using custom errors and wri...
    - Paging Certain # records per page .NET style
    - General Methods of formatting and Subtractin...
    - .NET LinkButton web control

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT