admin管理员组文章数量:1289830
I have a filedset and legend inside that with "some text" and inside this fieldset i have a GRID
I have 2 questions
How to show ? hide html filedset from code behind, i tried the following way to show and hide the field set
a) set runat="server"--but it didnt work b) i pasted the fieldset inside an asp panel and tried to show/hide the panel, it also didnt work
- How to set text for legend from code behind , ie I want to set "some text" + Value_Form_Code Behind AS leged text
Note :I am using "Rad Ajax Manager" and Rad Ajax LoadingPanel
I have a filedset and legend inside that with "some text" and inside this fieldset i have a GRID
I have 2 questions
How to show ? hide html filedset from code behind, i tried the following way to show and hide the field set
a) set runat="server"--but it didnt work b) i pasted the fieldset inside an asp panel and tried to show/hide the panel, it also didnt work
- How to set text for legend from code behind , ie I want to set "some text" + Value_Form_Code Behind AS leged text
Note :I am using "Rad Ajax Manager" and Rad Ajax LoadingPanel
Share Improve this question edited Nov 7, 2013 at 7:12 Arun CM asked Nov 7, 2013 at 5:32 Arun CMArun CM 3,4352 gold badges30 silver badges35 bronze badges4 Answers
Reset to default 4<asp:Panel ID="Panel1" runat="server" >
<fieldlset>
<legend><asp:Label id="Label1" runat="server" /></legend>
</fieldset>
</asp:Panel>
How to show /hide html filedset from code behind ?
Panel1.Visible = true; // or false
How to set text for legend from code behind , ie I want to set "some text" + Value_Form_Code Behind AS legend text ?
Label1.Text = String.Format("some text {0}",Value_Form_Code);
it should also be possible to add an ID
and runat="server"
to your fieldset and control visibility through code-behind. Just remember to write 'ID' in upper letters.
<fieldset ID="myFieldset" runat="server">
You won't be able to control the legend text, unless you give it an ID and runat itself. But visibility is absolutely possible.
The upside of this approach is: no needless html markup (Panel would be extra div). The downside: fieldsets are not really asp-controls, so some things might give you exceptions, so use carefully.
I use this approach only when I want to prevent controls from rendering at all in certain cases (visibility does that).
1: I think you should put your fieldset inside an asp:panel and then hide/show the panel from your code-behind. This will automatically hide/show your fieldset.
2: As far as setting the legend text is concerned, just set the legend with runat="server" and set the code from codebehind.
When you set the 'GroupingText' property of the asp:panel control then It will render as the 'fieldset' tag in HTML and whatever set in the 'GroupingText' property value is rendered as the <legend>
tag.
I think following code will help you as per your requirement.
For Design side,
<asp:Panel runat="server" ID="Panel1" GroupingText="This is legend">
<h4>Your Content Goes Here</h4>
</asp:Panel>
<br />
<asp:Button ID="btnHidePanel" runat="server" Text ="Hide FieldSet" onclick="btnHidePanel_Click" />
<asp:Button ID="btnShowPanel" runat="server" Text ="Show FieldSet" onclick="btnShowPanel_Click" Visible="false" />
For Code-behind try this,
protected void btnHidePanel_Click(object sender, EventArgs e)
{
Panel1.Visible = false;
btnHidePanel.Visible = false;
btnShowPanel.Visible = true;
}
protected void btnShowPanel_Click(object sender, EventArgs e)
{
Panel1.Visible = true;
Panel1.GroupingText = "This Legend Text Has been Changed";
btnHidePanel.Visible = true;
btnShowPanel.Visible = false;
}
本文标签: cHow to show and hide html fieldset And also Set legend text from AspNet Code behindStack Overflow
版权声明:本文标题:c# - How to show and hide html fieldset And also Set legend text from Asp.Net Code behind - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741441394a2378939.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论