0

Below is my client code to define an asyncfileupload control of ajax control toolkit and a label which i want to change text of

<asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server" OnUploadedComplete="AsyncFileUpload1_UploadedComplete"  />
<label id="lbl">hello</label>

and below is my code behind event handler of upload complete

  protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {

            if (AsyncFileUpload1.HasFile)
            {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "LableText", "ChangeLableText();", true);

            }
    }

Here is my ChangeLableText function on client side

 <script type="text/javascript">
    function ChangeLableText() {
        $("#lbl").html("Hello world");
        alert("I have been Called");

    }

I get the alert on client saying "I have been called" but I see no change in label text. I have tried placing the File upload and label inside an update panel but nothing seems to work for me. Any Help please.

umer
  • 1,196
  • 1
  • 14
  • 33
  • Can you debug jquery call? What $("#lbl") returns? – Mikhail Tymchuk Nov 16 '15 at 09:20
  • it returns "Hello World" , e.g the changed text which i want to be displayed , but apparently its doesn't change the label text – umer Nov 16 '15 at 09:39
  • i have found this helping blog, which explains the cause but not a solution to problem http://forums.asp.net/t/1479864.aspx?AsyncFileUpload+UploadedComplete+event+does+not+allow+updates+to+UpdatePanel – umer Nov 16 '15 at 09:45
  • no, I don't mean `$("#lbl").html("Hello world");` construction, I mean `$("#lbl")` only. What do you see when you call `$("#lbl").html();` before you set new HTML? – Mikhail Tymchuk Nov 16 '15 at 12:04
  • i have diagnosed the problem , i have changed the header of my question as well accordingly , the problem is that asynchfileupload doesn't work like update panel , e.g after the partial post back , update panel doesn't refresh itself , – umer Nov 16 '15 at 13:04
  • Did you try utilize client event `OnClientUploadComplete` instead of server `OnUploadedComplete`? – Mikhail Tymchuk Nov 17 '15 at 11:40
  • @MikhailTymchuk I want to use Server side OnUploaded Complete because based on the file uploaded which is an excel file i want to read through the file using EP Plus and return a json formatted file on client , This is not possible inside Client Uploaded Complete method i think . – umer Nov 17 '15 at 12:15
  • No, but none of this methods designed to do this. They just indicating, that upload is complete and no return data is intended to be sent. Maybe you can wait for client event to occur and then run separate ajax call to server to retrieve your json file? – Mikhail Tymchuk Nov 17 '15 at 16:10
  • @Mikhail I actually have no option to refresh the page after the file upload, I just need an instant response from server just after the file uploaded, I have come to know that probably Ajax AsynchFileUploader can't help me on this, This uploader no doubt posts file through ajax call to the server and i can get a response back from server, But there is some issue with its working i think , I can't make any visible changes to the form with this callback , may be its the issue with the ViewState which remains unchanged and form persists its state whether i try make a change or not – umer Nov 18 '15 at 05:54
  • Possible duplicate of [AjaxControlToolkit AsyncFileUpload - how to modify a label text value in UploadedComplete event](http://stackoverflow.com/questions/14760462/ajaxcontroltoolkit-asyncfileupload-how-to-modify-a-label-text-value-in-uploade) – Yuriy Rozhovetskiy Nov 18 '15 at 08:50

0 Answers0