Monday 25 May 2015

Enabled = False VS Readonly = True

Enabled = FalseVS Readonly = True
Hmmm, both of them have same function, as to disable editable operation in a property toolbox such as TextBox.

But I don't know, some of my textbox which I set the enabled = false, then I can't get the value of the textbox. I search some people said that "If we want  to pass the value we can use readonly = true, but if we wont we can just use enabled = true". Yeahh, that's right.

But why in some textbox I can pass value by using enabled = false????

Monday 18 May 2015

How to set DateTime NULL

Sometimes we need to set a datetime column to be NULL in SqlServer, but DateTime is a value type.
Follow this tutorial, I can set a column which has DateTime type to be NULL.

Set DateTime Null

Sunday 17 May 2015

CausesValidation

Hemm, I have a button that i put in a DIV like as:

<div id="FormKosong" class="white_content">
                         <table cellpadding=0 cellspacing=0 border=0 style="background-color:#3c8ebd;" width="100%">
                             <input id="hdn" type="hidden" runat="server">
                             <tr>
                                 <td height="16px">
                                        <a href = "javascript:void(0)" onclick = "document.getElementById('FormKosong').style.display='none';document.getElementById('fadeKosong').style.display='none'">
                                            <img src="../../Images/close.png" style="border :0px"  width="15px" align="right" height="15px"/>
                                        </a>
                                 </td>
                             </tr>

                            <tr>
                                <td style="padding-left:7px;padding-right:7px;padding-bottom:7px">
                                <table align="center"  border="0" cellpadding="0" cellspacing="0" style="background-color:#fff" width="100%">
                                    <tr>
                                        <td align="center" colspan="2"><h2>Form Register Rawat Inap</td>
                                    </tr>
                                    <tr>
                                        <td>&nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td align="center">
                                          <table>
                                               <tr>
                                                <td align="left"><asp:Label ID="Label2" runat="server" Text="Id Class" Width="120px"></asp:Label></td>
                                                <td><asp:TextBox ID="txtIdClassKosong" class="form-control" runat="server" Text='<%# Session["Class_Id"] %>' placeholder="Id Class" Width="100%" BorderColor="#3c8ebd" BorderStyle="Solid" BorderWidth="1px"></asp:TextBox>
                                                    <asp:RequiredFieldValidator id="RequiredFieldValidatorUserPassword" runat="server" ControlToValidate="txtIdClassKosong"
                                                    ErrorMessage="Id Class tidak boleh kosong" ForeColor="Red" ValidationGroup="grplogin"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                               <tr>
                                                <td align="left"><asp:Label ID="Label3" runat="server" Text="Id Room" Width="120px"></asp:Label></td>
                                                <td><asp:TextBox ID="txtIdRoomKosong" class="form-control" Text='<%# Session["Room_Id"] %>' runat="server" placeholder="Id Room" Width="100%" BorderColor="#3c8ebd" BorderStyle="Solid" BorderWidth="1px"></asp:TextBox>
                                                    <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ControlToValidate="txtIdRoomKosong"
                                                    ErrorMessage="Id Room tidak boleh kosong" ForeColor="Red" ValidationGroup="grplogin"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                               <tr>
                                                <td align="left"><asp:Label ID="Label4" runat="server" Text="Id Bed" Width="120px"></asp:Label></td>
                                                <td><asp:TextBox ID="txtIdBedKosong" class="form-control" runat="server"  placeholder="Id Bed" Width="100%" BorderColor="#3c8ebd" BorderStyle="Solid" BorderWidth="1px"></asp:TextBox>
                                                    <asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ControlToValidate="txtIdBedKosong"
                                                    ErrorMessage="Id Bed tidak boleh kosong" ForeColor="Red" ValidationGroup="grplogin"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                               <tr>
                                                
                                                 <td align="left"><asp:Label ID="Label27" runat="server" Text="Status Bed" Width="120px"></asp:Label> </td>
                                                 <td><asp:TextBox ID="txtStatusBedKosong" class="form-control" runat="server" placeholder="Status Bed" Width="100%" BorderColor="#3c8ebd" BorderStyle="Solid" BorderWidth="1px"></asp:TextBox>
                                                     <asp:RequiredFieldValidator id="RequiredFieldValidator11" runat="server" ControlToValidate="txtStatusBedKosong"
                                                     ErrorMessage="Status Bed tidak boleh kosong" ForeColor="Red" ValidationGroup="grplogin"></asp:RequiredFieldValidator>
                                                 </td>
                                             </tr>
                                              <tr>
                                                
                                                 <td align="left"><asp:Label ID="Label1" runat="server" Text="Id Register" Width="120px"></asp:Label> </td>
                                                 <td><asp:TextBox ID="txtIdRegister" class="form-control" runat="server" placeholder="Id Register" Width="100%"  BorderColor="#3c8ebd" BorderStyle="Solid" BorderWidth="1px" ></asp:TextBox>
                                                     <asp:RequiredFieldValidator id="RequiredFieldValidatorIdRegister" runat="server" ControlToValidate="txtIdRegister"
                                                     ErrorMessage="Id Register tidak boleh kosong" ForeColor="Red" ValidationGroup="grplogin"></asp:RequiredFieldValidator>
                                                 </td>
                                             </tr>
                                              <tr>
                                                
                                                 <td align="left"><asp:Label ID="Label9" runat="server" Text="Description" Width="120px"></asp:Label> </td>
                                                 <td>
                                                     <textarea id="txtDescriptionKosong" name="txtDescriptionKosong" cols="33" rows="2" style="border-style:solid; border-width:1px; border-color:#3c8ebd"></textarea>
                                                 </td>
                                             </tr>
                                            <tr>
                                                <td align="left"><asp:Label ID="Label5" runat="server" Text="Start Date" Width="120px"></asp:Label></td>
                                                <td style="padding-top:10px; padding-bottom:10px;">
                                                    <dx:ASPxDateEdit ID="DateStartDate" runat="server" Width="278px" EditFormat="DateTime" Border-BorderColor="#3c8ebd" Border-BorderWidth="1px" Height="30px"  ></dx:ASPxDateEdit>
                                                </td>
                                            </tr>
                                              <tr>
                                                <td align="left"><asp:Label ID="Label6" runat="server" Text="End Date" Width="120px"></asp:Label></td>
                                                <td style="padding-top:10px; padding-bottom:10px;"">
                                                    <dx:ASPxDateEdit ID="DateEndDate" runat="server" Width="278px" EditFormat="DateTime" Border-BorderStyle="Solid" Border-BorderColor="#3c8ebd" Border-BorderWidth="1px" Height="30px" ></dx:ASPxDateEdit>
                                                </td>
                                            </tr>
                                            
                                            <tr>
                                                <td></td>
                                                <td><asp:Button ID="btnReg" class="btn bg-olive btn-block" OnClick="register" CommandName="register" runat="server" Text="Register" Width="100%" height="30px" ValidationGroup="grplogin" CausesValidation="false" />
                                                </td>
                                            </tr>
                                          </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td height="10px"></td>
                                    </tr>
                                 </table>
                               </td>
                            </tr>
                         </table>
                        <div align="center" class=" headertext">
                        <asp:Label ID="txtlbl" runat="server"  ></asp:Label></div>
                        </div>
                        <div id="fadeKosong" class="black_overlay"></div>

And the problem is OnClick on the button does not work. I search and then I found the answer in this site CausesValidation. I just added CausesValidation="false" in my button.. :) :)