Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-22-2011, 03:51 PM   PM User | #1
esb01
New Coder

 
Join Date: Jun 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
esb01 is an unknown quantity at this point
Show <div> on postback

I'm sure I have pretty simple question but for some reasons I can't find answer

I have a basic JS function to show an element

function show(obj1) {
var div = document.getElementById(obj1);
div.style.display = 'inline';
}
.....

<a onclick="show('Div')>Show Panel</a>

<div id="Div" runat="server" style="display: none">
<table><tr><td>
...Controls
</td></tr>
<tr><td>
<asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click" />
</td></tr>
</table>
</div>

Displaying the panel is not a problem but how do I keep it shown on a postback (btnSearch_click)?

protected void btnSearch_Click(object sender, EventArgs e)
{
//Do something
//tried
Div.Attributes.Add("display", "inline'");
//and Div.Style("display") = "inline";
//and Div.Visible = true;
}

no matter what I do, it gets hidden.
esb01 is offline   Reply With Quote
Old 08-06-2011, 07:02 PM   PM User | #2
dotnetmind
New Coder

 
Join Date: Aug 2011
Posts: 50
Thanks: 0
Thanked 2 Times in 2 Posts
dotnetmind is an unknown quantity at this point
Postback event

have you tried this :


Div.Visible = Page.IsPostBack
dotnetmind is offline   Reply With Quote
Old 08-07-2011, 01:39 AM   PM User | #3
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
i have only ever run into problems with setting runat="server" to my divs.. usually i loose all my CSS attributes... My soltion (and what seems to be "better practice") is "wrapping" the div in question in a panel and showing/hiding the panel on postback... this works better (imo)...
__________________

I code C hash-tag .Net
Reference: W3C W3CWiki .Net Lib
Validate: html CSS
Debug: Chrome FireFox IE
alykins is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:03 PM.


Advertisement
Log in to turn off these ads.