473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

how to access html <hr> in code-behind?

Hi,

1)
i defined a html line in the aspx file like this but it's still visible::
<hr id="hr1" visible="false" />

So i defined it like this and now it's hidden:
<hr id="hr1" style="visibility:hidden" />

My first question: why does it not work with property 'visible' (it's
present in the dropdownlist of Visual Web Dev.)?
2)
In code-behind, i want to make it visible:
Dim hr As HtmlControl
hr = FindControl("hr1")
hr.Style("visibility") = "visible"

bit this gives an error (Object reference not set to an instance of an
object)
on line "hr.Style("visibility") = "visible"
What's wrong with this code?
Thanks for help
Mich


Mar 7 '07 #1
13 5865
"Mich" <ss**@xxcv.azwrote in message
news:uu**************@TK2MSFTNGP05.phx.gbl...
What's wrong with this code?
You've forgotten runat="server"
Mar 7 '07 #2
Ok, thanks, but i still get the same error:
<hr id="hr1" runat="server" visible="false" />

Code-behind:
Dim hr As HtmlControl
hr = FindControl("hr1")
hr.visible= True
"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:ev**************@TK2MSFTNGP03.phx.gbl...
"Mich" <ss**@xxcv.azwrote in message
news:uu**************@TK2MSFTNGP05.phx.gbl...
>What's wrong with this code?

You've forgotten runat="server"

Mar 7 '07 #3
"Mich" <ss**@xxcv.azwrote in message
news:e5**************@TK2MSFTNGP04.phx.gbl...
Ok, thanks, but i still get the same error:
Works for me... Code follows:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<hr id="hr1" runat="server" visible="false" />
</form>
</body>
</html>
Partial Class _Default
Inherits System.Web.UI.Page

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim hr As HtmlControl
hr = FindControl("hr1")
hr.Visible = True
End Sub

End Class
Mar 7 '07 #4
Sorry, i forgot to mention that the page with the <hris linked to a master
page:

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<hr id="hr1" runat="server" visible="false" color="#008080" /><br />
</asp:Content>


"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:O4**************@TK2MSFTNGP04.phx.gbl...
"Mich" <ss**@xxcv.azwrote in message
news:e5**************@TK2MSFTNGP04.phx.gbl...
>Ok, thanks, but i still get the same error:

Works for me... Code follows:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<hr id="hr1" runat="server" visible="false" />
</form>
</body>
</html>
Partial Class _Default
Inherits System.Web.UI.Page

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim hr As HtmlControl
hr = FindControl("hr1")
hr.Visible = True
End Sub

End Class

Mar 7 '07 #5
"Mich" <ss**@xxcv.azwrote in message
news:uL*************@TK2MSFTNGP06.phx.gbl...
Sorry, i forgot to mention that the page with the <hris linked to a
master page:
Is there anything else you've forgotten to mention...?
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<hr id="hr1" runat="server" visible="false" color="#008080" /><br />
</asp:Content>
So is the code running behind the MasterPage or the content page...?
Mar 7 '07 #6
this is the code-behind of the content page

"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:Om**************@TK2MSFTNGP02.phx.gbl...
"Mich" <ss**@xxcv.azwrote in message
news:uL*************@TK2MSFTNGP06.phx.gbl...
>Sorry, i forgot to mention that the page with the <hris linked to a
master page:

Is there anything else you've forgotten to mention...?
><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<hr id="hr1" runat="server" visible="false" color="#008080" /><br />
</asp:Content>

So is the code running behind the MasterPage or the content page...?

Mar 7 '07 #7
"Mich" <ss**@xxcv.azwrote in message
news:ei**************@TK2MSFTNGP03.phx.gbl...
this is the code-behind of the content page
You've forgotten to post it...
Mar 7 '07 #8
Mark, this was the answer on your question:
"So is the code running behind the MasterPage or the content page...?"
My answer is: "this is the code-behind of the content page"

The code is the same as already posted:
Dim hr As HtmlControl
hr = FindControl("hr1")
hr.visible= True
"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:%2****************@TK2MSFTNGP05.phx.gbl...
"Mich" <ss**@xxcv.azwrote in message
news:ei**************@TK2MSFTNGP03.phx.gbl...
>this is the code-behind of the content page

You've forgotten to post it...

Mar 7 '07 #9
"Mich" <ss**@xxcv.azwrote in message
news:eJ**************@TK2MSFTNGP04.phx.gbl...
Mark, this was the answer on your question:
"So is the code running behind the MasterPage or the content page...?"
My answer is: "this is the code-behind of the content page"

The code is the same as already posted:
Dim hr As HtmlControl
hr = FindControl("hr1")
hr.visible= True
Sorry - I appreciate that English isn't your first language...

I'm not sure what the problem is - this works fine for me in a content
page...
Mar 7 '07 #10
Mark,

I give you the whole code-behind to be sure i didn't forget more things:
this gives the error "Object reference not set to an instance of an object."
at the line: " hr.Visible = True"
When the user clicks on the Select Button of the gridview, the line must
appear (and also a detailsview not mentioned here).

Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles GridView1.SelectedIndexChanged
DetailsView1.Visible = True
Dim hr As HtmlControl
hr = FindControl("hr1")
hr.Visible = True
End Sub

The aspx-file:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True"
......
</asp:GridView>
<hr id="hr1" runat="server" visible="false" color="#008080" />
.....
</asp:Content>

"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
"Mich" <ss**@xxcv.azwrote in message
news:eJ**************@TK2MSFTNGP04.phx.gbl...
>Mark, this was the answer on your question:
"So is the code running behind the MasterPage or the content page...?"
My answer is: "this is the code-behind of the content page"

The code is the same as already posted:
Dim hr As HtmlControl
hr = FindControl("hr1")
hr.visible= True

Sorry - I appreciate that English isn't your first language...

I'm not sure what the problem is - this works fine for me in a content
page...

Mar 7 '07 #11
I have just tried again with a new normal page (no link to a masterpage) ...
it works.
I retried with a new page but linked to a masterpage ... it fails

So my conclusion is that this doesn't work within a content page ...
No way to go around that problem?

"Mich" <ss**@xxcv.azschreef in bericht
news:e8**************@TK2MSFTNGP02.phx.gbl...
Mark,

I give you the whole code-behind to be sure i didn't forget more things:
this gives the error "Object reference not set to an instance of an
object." at the line: " hr.Visible = True"
When the user clicks on the Select Button of the gridview, the line must
appear (and also a detailsview not mentioned here).

Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles GridView1.SelectedIndexChanged
DetailsView1.Visible = True
Dim hr As HtmlControl
hr = FindControl("hr1")
hr.Visible = True
End Sub

The aspx-file:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True"
.....
</asp:GridView>
<hr id="hr1" runat="server" visible="false" color="#008080" />
....
</asp:Content>

"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
>"Mich" <ss**@xxcv.azwrote in message
news:eJ**************@TK2MSFTNGP04.phx.gbl...
>>Mark, this was the answer on your question:
"So is the code running behind the MasterPage or the content page...?"
My answer is: "this is the code-behind of the content page"

The code is the same as already posted:
Dim hr As HtmlControl
hr = FindControl("hr1")
hr.visible= True

Sorry - I appreciate that English isn't your first language...

I'm not sure what the problem is - this works fine for me in a content
page...


Mar 7 '07 #12
"Mich" <ss**@xxcv.azwrote in message
news:eP**************@TK2MSFTNGP02.phx.gbl...
So my conclusion is that this doesn't work within a content page ...
No way to go around that problem?
Yep, and if you'd mentioned MasterPage / content page at the beginning,
you'd have had your answer hours ago... :-)

Remove these two lines:

Dim hr As HtmlControl
hr = FindControl("hr1")

And change this line:

hr.Visible = True

to

hr1.Visible = True
Mar 7 '07 #13
Yes, it works now. Thanks.Too simple to be found.
But, and referencing to your remark about mentioning masterpage, i also
tried with a 'normal' page (no masterpage linked) and .. it works too.
So it's not a exclusive solution for content page, is it?
"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
"Mich" <ss**@xxcv.azwrote in message news:ePgClIO
ma*********@TK2MSFTNGP02.phx.gbl...
>So my conclusion is that this doesn't work within a content page ...
No way to go around that problem?

Yep, and if you'd mentioned MasterPage / content page at the beginning,
you'd have had your answer hours ago... :-)

Remove these two lines:

Dim hr As HtmlControl
hr = FindControl("hr1")

And change this line:

hr.Visible = True

to

hr1.Visible = True

Mar 7 '07 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
by: Mark Moore | last post by:
It looks like there's a pretty serious CSS bug in IE6 (v6.0.2800.1106). The HTML below is validated STRICT HTML 4.01 and renders as I would expect in Opera, FrontPage, and Netscape. For some...
2
by: Jeremy Collins | last post by:
Hi all, How do I specify "noshade" as the style for an <HR> element in my style sheet? hr { height: 1px; color: #EEEEEE; ???? }
11
by: Ted Mayett | last post by:
OK. Here is a glitch, sorry if this has been mentioned before. This is an erratic glitch. I am now up to three other people besides myself who have been able to see this glitch. It seems it...
4
by: Matthias Göbels | last post by:
Hi everyone, I have a problem with the <hr /> - TAG. My aim is to produce a thin line with 1px height. That's no problem, with CSS it is working well. width: 170px; height: 1px; overflow:...
1
by: Matthias Göbels | last post by:
Hi everyone, I have a problem with the <hr /> - TAG. My aim is to produce a thin line with 1px height. That's no problem, with CSS it is working well. width: 170px; height: 1px; overflow:...
12
by: maya | last post by:
amazing, the stupid things IE does sometimes... inserted a simple <hrtag in sidenav here, www.francesdelrio.com/photoblog_new/india/page9/photos.jsp in FF it looks fine, in IE (both 6 and 7)...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.