469,625 Members | 1,568 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

.style.display = "None" won't stick

Sue
Help! I have an asp table with an embedded table. The asp
tablerow that contains this table has a static ID assigned
of "FilterRow2" (see snippets of code below). When I click
on the button to set the tablerow style property
to "None", the row (And embedded table) briefly disappear,
but then bounce right back into sight.

Any ideas on why it's doing this and how to make the
style.display = "None" stick?

tia,
Sue

control declared in .aspx page:

<asp:TableRow ID="FilterRow2" Runat="server">
<asp:TableCell Runat="server"
columnspan="6">

I have a client-side VBScript sub that sets the
DHTML "display" property of this FilterRow2 to "None"
or "InLine" triggered by a click on ASP Buttons.
These scripts are added to the project using
RegisterClientScriptBlock (see snip of the .aspx code-
behind below):

Me.ClientScriptString = "<script language=VBScript>" &
vbCrLf _
& " sub HideFilters()" & vbCrLf _
& " document.all(" & Chr(34) & Me.FilterRow2.ClientID & Chr
(34) & ").style.display = " & Chr(34) & "None" & Chr(34) &
vbCrLf _
& " end sub " & vbCrLf & "<" _
& "/" _
& "script>"

If (Not Page.IsClientScriptBlockRegistered("HideFilters"))
Then
Page.RegisterClientScriptBlock("HideFilters",
ClientScriptString)
End If

Here's the source code for the generated .ASPX page in an
IE browser:

<script language=VBScript>
sub HideFilters()
document.all("_ctl2_FilterRow2").style.display
= "None"
end sub
</script>

Here's the TableRow object in the source code in IE:

<tr id="_ctl2_FilterRow2">
Nov 18 '05 #1
5 9607
Hi Sue,

I am interested in this issue and researching on it now. I will update you
as soon as possible.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #2
Hi Sue,

Please let me know how the client-side vbscript was called. Is there a
postback to the server following the call to that vbscript? If it is the
case (I mean there is a postback after the call to the script), the display
style property will be reset by the server-side rendering.

Please let me know more detailed on your code. I certainly appreciate your
time.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #3
Sue
>Please let me know how the client-side vbscript was
called. Is there a
postback to the server following the call to that

vbscript? If it is the

There *shouldn't* be a post-back - that's what I'm trying
to avoid,
but maybe there's an implicit one I'm not aware of?
How could I test for this? thanks for help! Sue

' button declarations
Protected WithEvents FilterShowFiltersButton As New Button
Protected WithEvents FilterHideFiltersButton As New Button

' assign properties, styles, etc.
With Me.FilterShowFiltersButton
.ID = "FilterShowFiltersButton"
.Attributes.Add("class", "button")
.Text = "Show Filter Options"
.Attributes.Add("onclick", "call ShowFilters()")
End With

With Me.FilterHideFiltersButton
.ID = "FilterHideFiltersButton"
.Attributes.Add("Class", "button")
.Text = "Hide Filter Options"
.Attributes.Add("onclick", "call HideFilters()")
End With
Nov 18 '05 #4
Hi Susan,

By checking the source code, it is noticed that the button that will invoke
the HideFilters() vbscript is a server-side web server control, which, by
default, will raise a postback when a clicked was imposed on it. In this
case, the result of executing the script inside the HideFilters() function
will be overridden by a new postback.

To avoid such a situation,

1. Encapsulate all the code that render the embedded table inside the "If
Not IsPostBack" code block. For example,

If Not IsPostBack Then
' code to create the embedded table goes here...
End If

2. Render a standard html button, that is <input type=button onclick='call
HideFilters()'>, to do the same thing, instead of using a server-side
button that will raise a postback.

Please let me know if it makes sense.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #5
Unless you have code on the server that also needs to run remove the
runat="server" from the TableRowID. What is happening is that the row
dissapears, then the server-side code takes over and a post is done then the
event code is run (if there is any). The form post causes all controls to
be loaded with thier initial values, which is why the item reappear again.If
you do not have any code that needs to run on the server side, by
eliminating the runat="server" tag you eliminate the posting of the form.

If you do have server side code that needs to run, then another option would
be to not use client-side code and simply use the FilterRow.Visible=False
command and the row will stay invisible. If there are multiple rows with
the same name in the main table you might have to get a little bit fancier
and use the FindControl method of the main table and then set the visible
property to false. Feel free to contact me if you have any questions about
the 2 options I have given you.

S. Shawn Mehaffie
PC************@hotmail.com

"Sue" <Su*@ojd.state.or.us> wrote in message
news:13*****************************@phx.gbl...
Help! I have an asp table with an embedded table. The asp
tablerow that contains this table has a static ID assigned
of "FilterRow2" (see snippets of code below). When I click
on the button to set the tablerow style property
to "None", the row (And embedded table) briefly disappear,
but then bounce right back into sight.

Any ideas on why it's doing this and how to make the
style.display = "None" stick?

tia,
Sue

control declared in .aspx page:

<asp:TableRow ID="FilterRow2" Runat="server">
<asp:TableCell Runat="server"
columnspan="6">

I have a client-side VBScript sub that sets the
DHTML "display" property of this FilterRow2 to "None"
or "InLine" triggered by a click on ASP Buttons.
These scripts are added to the project using
RegisterClientScriptBlock (see snip of the .aspx code-
behind below):

Me.ClientScriptString = "<script language=VBScript>" &
vbCrLf _
& " sub HideFilters()" & vbCrLf _
& " document.all(" & Chr(34) & Me.FilterRow2.ClientID & Chr
(34) & ").style.display = " & Chr(34) & "None" & Chr(34) &
vbCrLf _
& " end sub " & vbCrLf & "<" _
& "/" _
& "script>"

If (Not Page.IsClientScriptBlockRegistered("HideFilters"))
Then
Page.RegisterClientScriptBlock("HideFilters",
ClientScriptString)
End If

Here's the source code for the generated .ASPX page in an
IE browser:

<script language=VBScript>
sub HideFilters()
document.all("_ctl2_FilterRow2").style.display
= "None"
end sub
</script>

Here's the TableRow object in the source code in IE:

<tr id="_ctl2_FilterRow2">

Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

68 posts views Thread by Marco Bubke | last post: by
42 posts views Thread by Alan McIntyre | last post: by
7 posts views Thread by Jeff Thies | last post: by
1 post views Thread by Tristan Miller | last post: by
77 posts views Thread by M.B | last post: by
8 posts views Thread by Steve Macleod | last post: by
26 posts views Thread by Frank Samuelson | last post: by
6 posts views Thread by bukzor | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.