Server Side ListBox Visibility with C# and ASP.NET -


I'm interested in using an "OnMousere" event to bombard and disappear. I am quite new with ASP.NET and I do not want to write Javascript right now. I am trying to use the following code, and its color changes part works, but the list box visibility does not work:

if (! IsPostBack) {Button2.Attributes.Add ("onmouseover "," This.style.backgroundColor = 'Red', ListBox3.style.visibility = 'visible' "); }

  if (! IsPostBack) {Button2.Attributes.Add ("onmouseout", "this.style.backgroundColor = 'Blue', ListBox3.style.visibility = 'hidden'"); }  

I have tried this code without "postback" and without, and there is still no luck. Does anyone see me why my code fails me?

Thanks,

DFM

Try:

/ P>
  if (! IsPostBack) {btnHide.Attributes.Add ("onmouseout", "this.style.backgroundColor = 'Blue'; ListBox3.style. Display = 'none');); BtnShow.Attributes.Add ("onmouseover", "this.style.backgroundColor = 'red'; ListBox3.style.display = 'block'"); }  

Visibility property works slightly different from property, when the visibility property is set to 'hidden' then the element is hidden but the layout is not affected, while the display property is' Anyone setting is completely removed from the element which can affect the layout.

If you want to modify the visibility of the without list that affects the layout, you can use a div as a cover and modify its visibility properties. You can.

  & lt; Div id = "wrapper" & gt; & Lt; ASP: Listbox ID = "ListBloc 3" Runat = "Server" & gt; & Lt; / Asp: List box & gt; & Lt; / Div & gt; & Lt; Asp: button id = "btnShow" runat = "server" text = "button" /> & Lt; ASP: Button ID = "BTN Hyde" Runat = "Server" Text = "Button" />  

Modify ASPX to toggle the visibility property of the div element that contains the list box.

  if (! IsPostBack) {btnHide.Attributes.Add ("on-houseout", "style.background color = 'blue'; wrapper style; visibility = 'hidden' '); BtnShow.Attributes.Add ("onmouseover", "this.style.backgroundColor =' red '; wrapper.style.visibility =' visible '");}  
< / Html>

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -