Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | Videos | Photos | Blogs | Beginners | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
DevExpress UI Controls
Search :       Advanced Search »
Home » VB.NET » ASP.NET HTML Postback Custom Control

ASP.NET HTML Postback Custom Control

Web form controls do not offer a complete solution to ASP.Net design and hence HTML tags are still required. Occasionally the need exists for a postback from an HTML tag, this article presents a Custom Control to address this requirement.

Page Views : 17497
Downloads : 210
Rating :
 Rate it
Level : Beginner
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
Html Post.zip
 
 
Team Foundation Server Hosting
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

Web form controls do not offer a complete solution to ASP.Net design and hence HTML tags are still required. Occasionally the need exists for a postback from an HTML tag, this article presents a Custom Control to address this requirement.

Introduction:

When using Map and Area tags, for instance, on a ASP.NET Web Form performing a postback to redirect the user to a new page is often needed. This can be addressed by using a User Control Hints and Tips or in the case of ASP.NET 2.0 new classes are available to address this requirement Server Event Handling in ASP.NER Web Pages. With ASP.NET 1.1 these classes are not available and using a Custom Control provides a very simple and compact solution.

Background:

 

The control consists of two elements; event handler, output render.

 

The event handler is standard "Click/Onclick" event code, which also includes a RaisePostbackEvent method to notify the control that it should handle an incoming postback event. This method extracts the event argument and saves it within the property variable htmlStr thereby enabling your code behind event method to read, test and take the appropriate action.

 

The render method outputs an anchor tag with no content text. Using the anchor tag ensures the inclusion of the _doPostBack JavaScript function while not having any content text between the tag pair means the anchor will not activate. The _doPostBack function can be called by any HTML tag using an onClick attribute and passing the custom control name, HtmlPostback1, as the event target and a user specified string as the event argument.

 

Using the code:

 

The above screen shot shows a simple test application of the Custom Control using a div tag to generate a postback and is included as part of the download code. The HtmlPostback Custom Control is dragged onto the web form, then as stated above a JavaScript call is made to the _doPostBack function by the required HTML tag.

A link is required between Custom Control event property htmlPost and the code behind event method. The test application code behind method HtmlPostback reads the argument string, ensures it is valid and then writes it to TextBox1 textbox.

 

Point of Interest:

 

As indicated above this is a very simple Custom Control with very few lines of code. The interest and novelty is in the application, which is described above.

NOTE: THIS ARTICLE IS CONVERTED FROM C# TO VB.NET USING A CONVERSION TOOL. ORIGINAL ARTICLE CAN BE FOUND ON C# Corner (http://www.c-sharpcorner.com/).

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Mike Knuckey
Mike Knuckey is a software consultant for Barnecourt Solutions www.barnecourt.co.uk, operating from Dartmoor, Devon, UK.
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Discover the top 5 tips for understanding .NET
Ricky Leeks presents the top 5 tips for understanding .NET Interoperability. Learn more.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
Team Foundation Server Hosting
Become a Sponsor
 Comments
Team Foundation Server Hosting
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.