SnapJag Creative Designs

ASP.NET

When creating a web control in an ASP.net application many times you will need to make references to information, data values and other contents of the web control from the web control parent. This is done by adding a Property statement on the control. It could be as simple as a Username and Password control to set or get the information at times of requesting login details.

Follow these steps to connect and use data on the User Web Control:

Create a new Web Control in your application project

Place two label and two textboxes on the control

Name the two controls txtUsername and txtAddress

In the code behind of the control add the following code (C#)private string username = String.Empty;
private string password; = String.Empty;

Drag and drop the new web control onto the web page canvas (if you already had the web control on your webpage and you added new interface elements (public functions or properties), you will likely need to remove the controls including the REGISTER statements at the top of the page so that the interface elements are reconnected to the page for you.

In the code behind the web page, make any references to the Tag name of the control (assuming “uc1” in this case) using the following statements (C#).this.uc1.Username = “Your username”;
this.uc1.Password{ = “Your password”;

This concludes the tutorial to add a simple web control and connect to it from the parent web page where it resides. This concept will help in many ways like, login pages, bread crumbs, contained lists, or other user interface lists.

A recent project caused me grief until it dawned on me what the problem and the fix was. The GridView has a height property value and if it’s changed from the default (which is NULL), or to anything less than 25px (arbitrary number) you may experience an undesierable result where the GridView will vertically align the rows in the middle of the control. I did this inadvertantly, creating this undesireable result, and I wanted to share with you the fix and why does this. Continue reading →