开发者

style on usercontrol doesn't work

Why isn't style attribute working on usercontrol?

This is my code:

<uc1:ucCredit runat="server" ID="ucCCard" style="display:none;" />

No开发者_运维技巧te: I do not want to set Visible=false. Doing this would not render the element at all which is what I don't want because I am manipulating the style and it's display through javascript.

Thanks in advance :)


Usercontrols don't have style property as far as I know. A quick fix would be to wrap your usercontrol into <span/> or <div/> and giving it appropriate id and then manipulating them in javascript.


This isn't working as the <uc1:ucCredit> tag isnt rendered.

Another idea might be to put something like this:

Markup:

<uc1:ucCredit runat="server" ID="ucCCard" Display="none" />

VB.NET:

Public Display as String

Sub Page_Load()
    If Not Display = Nothing then
        div.attributes("style") = string.format("display:{0};", display)
    End IF
End Sub

In this example div is a div which is wrapped around the content in the user control


You can not use style attribute there, because the usercontrol not rendered as an HTML element. I would suggest to wrap it to a div.

<div style="display:none;">
    <uc1:ucCredit runat="server" ID="ucCCard"  />
</div>


You can make a property in the user control which will identify if the user control is visible or not and you have to put all your controls in a panel and set it's display to none

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜