开发者

ASP.NET Usercontrol Property value does not run <%= markup

Well i have a us开发者_运维百科ercontrol with a property "ClientScript" and in the aspx file where i use the usercontrol i set the value to =document.getElementsByName('<%=ReportViewer1.ClientId %>$ctl01$ctl07$ctl00$ctl00$ctl00')[0].click(); return false;

the problem here is that the is litterly passed to the property and not parsed first and replaced by the ClientID..

I had the same clientscript applied to a buttons OnClientClick and there it worked...

Must i apply some sort of attribute to the property to get this working?

here is my code:

Usercontrol.ascx.vb

<ParseChildren(True), PersistChildren(False), Themeable(False)>
Public Class CommandPanel
    Inherits System.Web.UI.UserControl

    Private mClientScript as string
    <Themeable(False), DefaultValue("")> _
    Public Property ClientScript As String
        Get
            Return mClientScript
        End Get
        Set(ByVal value As String)
            mClientScript = value
        End Set
    End Property
End Class

Page.aspx

<%@ Register src="UserControls/CommandPanel.ascx" tagname="CommandPanel" tagprefix="uc1" %>
......
<uc1:CommandPanel ID="CommandPanel1" runat="server" ClientScript="document.getElementsByName('<%= ReportViewer1.ClientId %>$ctl01$ctl07$ctl00$ctl00$ctl00')[0].click(); return false;" />
......

Note: i know that im saving to a local variable and that it will be cleared on reload and so on but thats not the problem here...


<%= expressions cannot be used in server-side controls. You can use <%# syntax (then you must call DataBind on user control) or Attributes property.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜