简体   繁体   中英

How to enable/disable textbox if the user already pick a file for upload using AsyncFileUpload?

I have an ASP code:

<ajax:AsyncFileUpload ID="fuFile" runat="server" Width="250px" />

with a textbox for description:

<asp:TextBox ID="txtFileDesc" runat="server" TextMode="MultiLine" Wrap="true" style=" resize: none" Height="50px" MaxLength="200"></asp:TextBox>

Now, I want to enable the txtFileDesc textbox if the user "PICKED A FILE" (when the background of the file path turns green) like this sample from http://www.asp.net .

I already tried the solution from other post's but none of them works for me.

you can handle OnClientUploadStarted client side event to disable textbox and OnClientUploadComplete event to enable textbox after file has been uploaded completely.

Your fileupload should be like

<ajax:AsyncFileUpload ID="fuFile" runat="server" Width="250px" OnClientUploadStarted="OnClientUploadStartedFn" OnClientUploadComplete="OnClientUploadCompleteFn"  />

call this function on OnClientUploadStarted

 function OnClientUploadStartedFn () {
    $('#textboxId').attr('readonly','readonly');
   }

call this function on OnClientUploadComplete

function OnClientUploadCompleteFn() {
    $('#textboxId').removeAttr('readonly');
   }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM