Hi friends...
am uploading a image file to folder... and as show below am using using a panel with ajax pop up extender.. in that i added the textbox control and fileupload control... but when click the button to upload.. the textbox value will be null... so how i to get rid off this bug...

<asp:UpdatePanel ID="Panel1"  ChildrenAsTriggers="false" UpdateMode="Conditional" runat="server">
                                                        <ContentTemplate>
                                                            <asp:Panel ID="Panel4" runat="server" Style="cursor: move; background-color: #DDDDDD;
                                                                border: solid 1px Gray; color: Black">
                                                                <table cellpadding="5px" width="100%">
                                                                    <tr>
                                                                        <td>
                                                                            <asp:TextBox ID="TextBoxDocuement" Text=""  Style="padding-right: 3px;" runat="server"></asp:TextBox>
                                                                            <ajaxToolkit:TextBoxWatermarkExtender ID="TextBoxDocuement_TextBoxWatermarkExtender"
                                                                                runat="server" Enabled="True" WatermarkText="Description" WatermarkCssClass="watermarked"
                                                                                TargetControlID="TextBoxDocuement">
                                                                            </ajaxToolkit:TextBoxWatermarkExtender>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td colspan="2">
                                                                            <asp:FileUpload ID="FileUpload1" runat="server" />
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Button ID="OkButton" OnClick="OkButton_Click" runat="server" CausesValidation="true"
                                                                                Text="Upload" />
                                                                            <asp:Button ID="CancelButton"  runat="server" Text="Cancel" />
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </asp:Panel>
                                                        </ContentTemplate>
                                                        <Triggers>
                                                            <asp:PostBackTrigger ControlID="OkButton" />
                                                        </Triggers>
                                                    </asp:UpdatePanel>
                                                    <ajaxToolkit:ModalPopupExtender ID="Panel1_ModalPopupExtender" runat="server" DynamicServicePath=""
                                                        PopupControlID="Panel1" BackgroundCssClass="modalBackground" PopupDragHandleControlID="Panel4"
                                                        Enabled="True" CancelControlID="CancelButton" TargetControlID="LinkButtonDocuementUpload">
                                                    </ajaxToolkit:ModalPopupExtender>


protected void OkButton_Click(object sender, EventArgs e)
    {
        ContentManagementSoap Service = new ContentManagementSoapClient();
        UPloadStudentDocumentRequest request = new UPloadStudentDocumentRequest();
        request.Body = new UPloadStudentDocumentRequestBody();

        bool fileOk = false;
        string path = Server.MapPath("~/Uploaded ImageFiles/") + FileUpload1.FileName;
        if (FileUpload1.HasFile)
        {
            string fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
            string[] allowedExtensions = { ".jpg", ".bmp", ".jpeg", ".gif" };
            for (int i = 0; i < allowedExtensions.Length; i++)
            {
                if (fileExtension == allowedExtensions[i])
                {
                    fileOk = true;
                }
            }
        }
        else
        {
            //exit();
        }

        if (fileOk)
        {
            Panel1.Update();
            if (TextBoxDocuement.Text.Length > 0)
            {
                Images ima = new Images();
                ima.DateCreated = DateTime.Now;
                ima.ImagePath = path;
                ima.ImageName = FileUpload1.FileName;
                FileUpload1.PostedFile.SaveAs(path);

                ima.ImageType = FileUpload1.PostedFile.ContentType;
                ima.ImageDescription = TextBoxDocuement.Text;
                User user = (User)Session["User"];
                ima.UserloginId = user.Id;

                StudentManagement.Student stud = (StudentManagement.Student)Session["Student"];
                request.Body.img = ima;
                request.Body.studentId = stud.StudentId;
                UPloadStudentDocumentResponse response = Service.UPloadStudentDocument(request);

                if (response.Body.UPloadStudentDocumentResult != false)
                {
                    GetDocumentList(stud);
                    LabelerrormsgDocument.Text = "File Uploaded Successfully!!";
                    Panel1.Update();
                    LabelerrormsgDocument.Visible = true;
                    TextBoxDocuement.Text = null;
                    //Panel1.Update();
                    // sanju DocumentDelete.Visible = false;
                    PanelDocumentDisplay.Visible = false;
                }
                else
                {
                    LabelerrormsgDocument.Text = "File Uploaded failed!!";
                    LabelerrormsgDocument.Visible = true;
                    TextBoxDocuement.Text = "";
               
                }
            }
            else
            {
                LabelerrormsgDocument.Text = "File Error!!";
                LabelerrormsgDocument.Visible = true;
                TextBoxDocuement.Text = "";
               
            }
        }

VinayRok,

Do not use UpdatePanel to upload an image. Try it without using UpdatePanel.

Use code tags.
>How?
- see

[CODE=C#] .... statements....

[/code]

Ya thanks it got solved....

Thanks,

Mark this thread as Solved if you get solution.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.