JavaScript How to show and hide html fieldset And also Set legend text from Asp.Net Code behind show hide html element,show hide html element based on

I have a filedset and legend inside that with "some text" and inside this fieldset i have a GRID

I have 2 questions

  1. 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.net panel and tried to show/hide the panel, it also didnt work

  2. 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

Answer:1
<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);
Answer:2

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).

Answer:3

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.

Answer:4

This is the link that I have: href='" . $ajax_like_link . "' data-task='like' data-post_id='" . $post_id . "' data-nonce='" . $nonce . "'>"; And I want to replace the displayed link value from ...

This is the link that I have: href='" . $ajax_like_link . "' data-task='like' data-post_id='" . $post_id . "' data-nonce='" . $nonce . "'>"; And I want to replace the displayed link value from ...

I have a for loop in php that adds a number of checkboxes on my page that look like this <input type="checkbox" name="checkbox[]"> I want to use javascript to check which is checked and add ...

I have a for loop in php that adds a number of checkboxes on my page that look like this <input type="checkbox" name="checkbox[]"> I want to use javascript to check which is checked and add ...

  1. remove some values from array php
  2. find some values in array

I wanted Two Google Maps API in single html file. SO I have done like following. But it is not working. Please help me by guiding why I cant and where I am mistaking? Thanks in advance. <html&...

I wanted Two Google Maps API in single html file. SO I have done like following. But it is not working. Please help me by guiding why I cant and where I am mistaking? Thanks in advance. <html&...

  1. longest possible google maps route
  2. longest possible drive google maps

I have to modify some code and the previous developer left this comment: color: color, // e.g. '#RRGGBBFF' - Last 2 digits are alpha information On the page there is a color picker that let's the ...

I have to modify some code and the previous developer left this comment: color: color, // e.g. '#RRGGBBFF' - Last 2 digits are alpha information On the page there is a color picker that let's the ...