1/1/10

Web User Control

Now  i want to make all the login form (with the datepicker enabled field) to be placed on the page as Web User Control.

Lets add to our project new web user control :
Right click on project->Add new item-> Web User Control
Lets call it DatePickerControl
copy  the markup code inside the
tag from the Default page (The page we worked on it in previous post)
and paste it inside the User Control markup
Now add a new webform and drag the  DatePickerControl.aspx into the new page.
Now you can compile and view this new page in browser.
Alas! Something got messed here...No more datepicker, no more validation.
The problem is that all the conrol attributes like id and name  changed.


<input name="DatePickerControl1$txtBirthDate" type="text" id="DatePickerControl1_txtBirthDate" name="txtBirthDate" style="height:24px;" />


One way to solve this problem is to register the javascript in the Load Page event of contol:
string script = "<script type=\"text/javascript\">$(function() {"+
        "$('#"+txtBirthDate.ClientID + "').datepick({maxDate: 0});"+


        "$('#form1').validate({" +
        "errorPlacement: $.datepick.errorPlacement," +
        "rules: {" +
         "txtBirthDate: { dpMaxDate: [] }" +

        "}," +
         "messages: {" +

          " txtBirthDate: '<span style=\"color:red\">The date is icorrent or later than now!</span>'" +
        " } " +
        "});" +
        "});</script>";
        Page.RegisterClientScriptBlock("datepickerfuncs",script);

Getting started with docker

It is very simple to get started usig docker. All you need to do-is download the docker desktop for your system Once you get docker syste...