Main

April 11, 2007

Custom Server Controls vs User Control

Custom controls compile to their own .dll file and can be used across applications.
User controls are limited to a single application.

Custom controls require no additional files beyond the .dll and are completely compiled.
User control must be deployed as an .ascx file, and the source code in the .ascx file will be visible to anyone with rights to view the files on the web server.

Custom controls can be display a design-time user interface that mimics what will be displayed at runtime.
User controls are always rendered as generic gray box.

Custom controls can be sized visually.
User controls can be sized only by setting properities.

Code to handle events exposed by custom controls can be largely generated automatically by VS.NET.
You will need to add all code by hand to handle an event exposed by a user control.

Tips
One should use a user control when reuse is only across a project.
When the control is used in a second project, take a few hours and turn it into a custom control.

April 10, 2007

RadioButtonList & SelectedValue

Before you want to use SelectedValue, you got to check if there is any item selected.

if(rblGrade.SelectedIndex != -1)
{
alValues.Add(rblGrade.SelectedItem.Value);
}


Before you set SelectedValue, you need to check if it is null.

if(dr["gender"] != DBNull.Value)
{
rblGender.SelectedValue = dr["gender"].ToString();
}

August 15, 2006

DataGrid -- With Template & Total Line

http://www.extremeexperts.com/Net/Articles/AddingControlstoFooter.aspx

http://localhost/JaneWeb/FFA/CDE/admin/CDEReportBySchool.aspx?type=fall

The key point is to overwrite ItemCreated event handler, and then design a proper footer with computed data in it.

http://aspalliance.com/494

July 21, 2006

Build dynamic controls upon administrors configuration

I've been working on an application which have event date time on all pages. This of course should be changed every year. And the allowance for each event might be different year to year too. As a support person, I am just tired of these tedious things. I'd rather build a new one for them.

In the new system, the admin would have the ability to configure the application by himself. This would include date and time of the events, how many teams are allowed for each school and how many members for each team. And the cool thing is all the other public registration pages and reports would be changed immediately. I don't need to go through all of them and change one by one. I don't need to worry about that I still might forget some which are supposed to be changed even though I've been tried hard. You know what? Relief!!! That's what I feel right now even though there is still a long way to finish all my coding. But I already pass the most hard part. Yeah!

Apply template in .net applications

Want to let your pages have identical look? Yah, why not? But how?

My first attempt is to use web user controls at top, bottom and also having one for side menu. It works! My customers like my design. So what's wrong I have to look for another alternative?

The problem with this implementation is I have to register all the user controls in every aspx pages and create properate tags for each of them. When you have many pages in your application, you could image how bothering this could be! Plus this is costly for future maintenance.

I got to find another way to do this, I told myself. And I diving into my R&D world. Finally I find one which is easy to implement and easy to apply. I am so excited!!!!

Here is the way. You implement a master page with all fancy looks you want, header, footer, side menus. And then all other page inherit it instead of Page. That's it! Sound easy? Yes. I do satisified with this one.

July 19, 2006

Create X Number of TextBox at Runtime

http://www.artisticode.com/Downloads/154.aspx

----------------------------------- Below is the contribution I made------------------------------------------

Clean Up when the number of textbox was changed
By ? on Wednesday, July 19, 2006 (PST)
If we don't cleanup everytime when the requrested number of textbox was changed, error or messy would be expected. Below is my solution:

private void cleanUp()

{

TextBoxesHere.Controls.Clear();

ltlReturnData.Text = "";

}

private void txtTBCount_TextChanged(object sender, System.EventArgs e)

{

cleanUp();

}