SIGN UP MEMBER LOGIN:    
ARTICLE

Building the ListBoxesFT_C ASP.NET Web User Control in Visual Studio 2005: Part V

Posted by Michael Livshitz Articles | Visual C# November 15, 2006
In multi-part article, I share how you can build your own ASP.NET web user control.
Reader Level:

We have built our control (part 1, part 2, part 3, part 4) and now there is time to check it. Drag and drop on the WF_ListBoxes form our control (ListBoxesFT_C1) , three button controls (ButtonBack with the text "Back", ButtonJust with the text "PostBack" and ButtonTestDTOut with the text "Test DT_Out") and GridViewTestDT_Out (fig. 4).

 

Figure 4.

 

With the help of the ButtonBack we "redirect" our test page to the previous page. With the help of the ButtonJust we just "force to work" the PostBack event and, thus, have an opportunity to check up "behaviour" of the control. With the help of the ButtonTestDTOut and the GridViewTestDT_Out we check up "output" of  our control (C_DataOut).


The code of the WF_ListBoxes is very simple:

 

public partial class WebForms_Test_WF_ListBoxes : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        GetData.GetDataHelp getData = new GetData.GetDataHelp(); 

        if (!IsPostBack)

        {

            //ListBoxesFT_C1.C_Client = false;

            //ListBoxesFT_C1.C_SortBy = 0;

            //ListBoxesFT_C1.C_HeightLB = 200;

            //ListBoxesFT_C1.C_WidthLB = 200;

            //ListBoxesFT_C1.C_SortByText = false;

            //ListBoxesFT_C1.C_LabelTo = "To";

            //ListBoxesFT_C1.C_LabelFrom ="From";

            ListBoxesFT_C1.C_DataIn =

            getData.getDataSetCities(10).Tables[0];

        }

    }

    protected void ButtonBack_Click(object sender, EventArgs e)

    {

        Response.Redirect("~/Default.aspx");

    }

    protected void ButtonTestDTOut_Click(object sender, EventArgs e)

    {

        GridViewTestDT_Out.DataSource = ListBoxesFT_C1.C_DataOut;

        GridViewTestDT_Out.DataBind();

    }

}

 

Now , for example , if your team leader chooses your control for checking up (fig. 5),

Figure 5.

 

he gets the following (fig 6.):

Figure 6.

 

He selects some items and clicks on the "Test DT_Out". The result is the following (fig. 7):

Figure 7.

 

He clicks on the "PostBack"! All is OK. He asks to change the C_Client property to "false" , the C_SortBy property to "0", the C_HeightLB and C_WidthLB properties to "200". He selects the same items and gets the result (fig. 8):

Figure 8.

 

OK! Your boss is satisfied by your work and authorizes to apply the control!

You can show the initiative and add such properties as : "C_Multiple" ,that allows to set selection mode of the ListBoxes to "multiple" ; "C_Validation", that allows to validate selected items with the help of a control (RangeValidator), added to the ListBoxesFT_C ; "C_Default", that allows to set default selected items ; etc.

We have built the control with the help of "clear server" and "clear client" technology. Such new features of ASP.Net 2.0 as the ICallbackEventHandler interface we will discuss in the next article.

CONCLUSION

I hope that this article will help you to recreate and test the ListBoxesFT_C control or to create and test your own web user control with your own requests in Visual Studio 2005.

Good luck in programming ! 

Login to add your contents and source code to this article
share this article :
post comment
 

Thank you !

Michael

Posted by Michael Livshitz Oct 26, 2007

Easy to understand and very useful. I write just to thank you publish these articles. Were very helpful in my first job in ASP.NET and JavaScript. Congratulations on the job, is very good.

Posted by Luis Carro Oct 22, 2007

Hi, Luiz!
First of all very carefully check out the code of your test form (part 5 of my article).
Pay your attention on two lines of the code:


GridViewTestDT_Out.DataSource = ListBoxesFT_C1.C_DataOut;           GridViewTestDT_Out.DataBind();

 and then - on the line:
ListBoxesFT_C1.C_Client = false;//true;

If the property is set to true, very carefully check out the JavaScript (part 3 of my article).
Thank you.
Best wishes.
Michael

 

Posted by Michael Livshitz Sep 30, 2007

Hi Michael, First of all, thanks a lot for this great article you shared with the community. I am getting an error when I click the button Test DT_Out tha says that _DT_In is null. I think I am loosing the DataTable after the PostBack action. I followed all steps you put in the article and I don't know what I am doing wrong. Maybe is a silly thing because I am new with VS and Web Design. Thanks, Luiz

Posted by Luiz Guimaraes Sep 28, 2007

Hi Michael, First of all, thanks a lot for this great article you shared with the community. I am getting an error when I click the button Test DT_Out tha says that _DT_In is null. I think I am loosing the DataTable after the PostBack action. I followed all steps you put in the article and I don't know what I am doing wrong. Maybe is a silly thing because I am new with VS and Web Design. Thanks, Luiz

Posted by Luiz Guimaraes Sep 28, 2007
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • 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.
    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.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor