开发者

Assigning dynamic client Id of the Form to a Static Method Result

开发者 https://www.devze.com 2023-03-30 16:19 出处:网络
I have more than one user controls with the javascript functions. I set control Id to the client functio开发者_JAVA技巧n - to separate it from another. My javascript code looks like:

I have more than one user controls with the javascript functions. I set control Id to the client functio开发者_JAVA技巧n - to separate it from another. My javascript code looks like:

    function <%= this.ClientID %>UploadComplete(sender, args) {
....
}

And I want to register this method in the control declaration,

<ajaxToolkit:AsyncFileUpload runat="server" OnClientUploadComplete ="<%#uploaderror.ClientID%>UploadComplete"
        ID="AsyncFileUpload"/>

But in mark-Up I got

{"uploadComplete":<%#ClientID%>UploadComplete},"

Where uploaderror- I tried to use Attributes:

protected void Page_Load(object sender, EventArgs e)
{
    AsyncFileUpload.Attributes.Add("OnClientUploadComplete", this.ClientID + "UploadComplete");
}

Mark-up was good. But event didn`t fire.

So I have two questions: 1) Why <%# - dont works. 2) Why added by attributes events dont fired in javascripts?

Thank you.


For your first question, the reason it doesn't work is that you cannot mix databinding code and text in a server control's property as you have done. It has to be one or the other. So what you could do instead is:

OnClientUploadComplete='<%# uploaderror.ClientID + "UploadComplete"%>'
0

精彩评论

暂无评论...
验证码 换一张
取 消