Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friend,I have some problem when implemented the code.The problem is How to implement Update Panel in edit form.Actually problem occures when i am trying to upload image if i am selected wrong file then give me error in server side this code is nice or their is no problem to me but when they have to give me error or rendering page in server side my whole page render on server side thats why my edit information should be refresh so i dont want to refresh that cotrol.Please give me information how to implemented update panel.
This is following my aspx code:-

XML
<asp:Panel runat="server" ID="EditEmployee" class="Employee" Style="display:none;">
            <div class="Employee-ct">
                <div class="Employee-header">
                    <h2>
                        Update Employee Details</h2>
                    <asp:LinkButton  ID="lnkEdit_Cancel" runat="server" CssClass="modal_close"></asp:LinkButton>
                    <asp:Panel ID="EditError" runat="server" CssClass="error" Visible="false"><asp:Label ID="lblEditError" runat="server" ></asp:Label></asp:Panel>
                </div>
                <div class="Errors" style="color: Red">
                </div>
                <asp:HiddenField runat="server" ID="EmpID" />

                        <div runat="server" id="mainpage">

                                  <div>
                                            <div class="txt-fld" style="height:30px;">
                                                <table>
                                                       <tr>
                                                            <td>
                                                                 <label for="" style="margin-bottom:14px">Name</label>
                                                            </td>
                                                            <td>
                                                            </td>
                                                            <td>
                                                                <asp:TextBox ID="txtName" runat="server" style="margin-left:-9px" ViewStateMode="Enabled"></asp:TextBox>
                                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*" ControlToValidate="txtName"
                                                                 ValidationGroup="EmployeeEdit" CssClass="form-valid"></asp:RequiredFieldValidator>
                                                            </td>
                                                       </tr>
                                                </table>

                                            </div>
                                            <div class="txt-fld" style="height:30px;">
                                            <table>

                                                 <tr>
                                                    <td>
                                                    <label for=""> Company</label>
                                                    </td>
                                                    <td>
                                                    </td>
                                                    <td>
                                                      <asp:DropDownList ID="drpCompany" runat="server" DataSourceID="SqlDataSource1" DataTextField="CompanyName" DataValueField="CompanyID" style="margin-left:-9px"></asp:DropDownList>
                                                      <asp:Label id="lbl_EditCompany" style="font-weight: bold;margin-left:-9px" runat="server" />
                                                    </td>
                                                </tr>
                                            </table>

                                            </div>
                                            <div class="txt-fld" style="height:30px;">
                                                <table>
                                                    <tr>
                                                        <td>
                                                            <label for="">Contact No</label>
                                                        </td>
                                                        <td>
                                                        </td>
                                                        <td>
                                                            <asp:TextBox runat="server" ID="txtContact" style="margin-left:-9px"></asp:TextBox><asp:RequiredFieldValidator
                                                                ID="RequiredFieldValidator9" runat="server" ErrorMessage="*" ControlToValidate="txtContact"
                                                                ValidationGroup="EmployeeEdit" CssClass="form-valid"></asp:RequiredFieldValidator>
                                                        </td>
                                                    </tr>
                                                </table>

                                            </div>

                                            <div class="txt-fld" style="height:35px">
                                                <table>
                                                     <tr>
                                                        <td>
                                                             <label for="" > Email</label>
                                                        </td>
                                                        <td>
                                                        </td>
                                                        <td>
                                                         <asp:TextBox runat="server" ID="txtEmail" style="margin-left:-9px"></asp:TextBox>
                            <%--                                  <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" CssClass="form-valid"
                                                        ErrorMessage="*" ControlToValidate="txtEmail" ValidationGroup="Employee"></asp:RequiredFieldValidator>--%>
                                                          <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                                        ControlToValidate="txtEmail" CssClass="form-valid" ErrorMessage="*" ValidationGroup="NewRegister"></asp:RegularExpressionValidator>
                                                        <%--
                                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ValidationExpression=" ^\w+@[a-zA-Z_]+?\.[(in)|(com)|(gov)|(org)|(info)|(co)|(net)]{2,3}$"
                                                        ControlToValidate="txtEmail" ValidationGroup="Employee" ErrorMessage="*"
                                                        CssClass="form-valid">  </asp:RegularExpressionValidator>--%>

                                                        </td>
                                                    </tr>
                                                </table>
                                             </div>

                                            <div class="txt-fld" style="height:30px;">
                                                <table>
                                                    <tr>
                                                        <td>
                                                             <label for="">Employee Code </label>
                                                        </td>
                                                        <td>
                                                        </td>
                                                        <td>
                                                            <asp:TextBox runat="server" ID="txt_EditEmployeeCode" style="margin-left:-9px"></asp:TextBox>

                                                        </td>
                                                    </tr>
                                                </table>


                                            </div>

                                            <div class="txt-fld" style="height:30px;">
                                                <table>
                                                    <tr>
                                                        <td>
                                                             <label for="">Address</label>
                                                        </td>
                                                        <td>
                                                        </td>
                                                        <td>
                                                             <asp:TextBox runat="server" ID="txt_EditAddress" style="margin-left:-9px"></asp:TextBox>
                                                        </td>
                                                    </tr>

                                                </table>
                                            </div>
                                      </div>
                              </div>

                <div class="txt-fld" style="height:40px;" >
                        <table>
                            <tr>
                                <td>
                                      <label for="" >Photo</label>
                                </td>
                                <td>
                                </td>
                                <td>
                                    <asp:FileUpload ID="photoupload_Update" runat="server" accept="gif|jpg|png|jpeg|bmp" style="margin-left:-9px" />
                                    <asp:RegularExpressionValidator id="RegularExpressionValidator2" runat="server" ErrorMessage="Upload Images only." CssClass="form-valid"
                                     ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.jpg|.png|.bmp|.jpeg|.gif)$" ControlToValidate="photoupload_Update">
                                     </asp:RegularExpressionValidator>
                                </td>
                             </tr>
                        </table>




                </div>

                <div class="btn-fld">
                    <asp:Button ID="btnEdit" Text="Save&raquo;" runat="server" ValidationGroup="EmployeeEdit"
                        OnClick="btnEdit_Click" />
                </div>
            </div>

</asp:Panel>


Thanks in advanced !!
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900