I'm not sure what I'm doing wrong. Here's my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim hyp As HyperLink = CType(Me.FindControl("hypFilt" &
Request.QueryString("Filt")), HyperLink)
If Not hyp Is Nothing Then
hyp.Font.Bold = True
EndIf
End If
I have several hyperlink controls on a page. Some are ID = hypFiltA,
hypFiltB, hypFiltC, etc. They are used to filter some data by first letter
of the alphabet. The code runs, nothing crashes but but the code above never
finds them. hyp always = nothing.
"hypFilt" & Request.QueryString("Filt") does evaluate out to the correct
value.
Thanks,
Keith 15 1299
I should mention that the hyperlink controls are not embeded inside another
control. They are in a content section but they are recognized by
intellisense when I type "me.hyp..." into the vb code page.
"Keith G Hicks" <kr*@comcast.netwrote in message
news:uF**************@TK2MSFTNGP05.phx.gbl...
I'm not sure what I'm doing wrong. Here's my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
Handles Me.Load
Dim hyp As HyperLink = CType(Me.FindControl("hypFilt" &
Request.QueryString("Filt")), HyperLink)
If Not hyp Is Nothing Then
hyp.Font.Bold = True
EndIf
End If
I have several hyperlink controls on a page. Some are ID = hypFiltA,
hypFiltB, hypFiltC, etc. They are used to filter some data by first letter
of the alphabet. The code runs, nothing crashes but but the code above
never
finds them. hyp always = nothing.
"hypFilt" & Request.QueryString("Filt") does evaluate out to the correct
value.
Thanks,
Keith
Set a breakpoint and see if the id is formed correctly, run Me.FindControl
in the watch window, see what is inside the Me.Controls collection. This
should help you to figure out what is going on.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Keith G Hicks" <kr*@comcast.netwrote in message
news:uF**************@TK2MSFTNGP05.phx.gbl...
I'm not sure what I'm doing wrong. Here's my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
Handles Me.Load
Dim hyp As HyperLink = CType(Me.FindControl("hypFilt" &
Request.QueryString("Filt")), HyperLink)
If Not hyp Is Nothing Then
hyp.Font.Bold = True
EndIf
End If
I have several hyperlink controls on a page. Some are ID = hypFiltA,
hypFiltB, hypFiltC, etc. They are used to filter some data by first letter
of the alphabet. The code runs, nothing crashes but but the code above
never
finds them. hyp always = nothing.
"hypFilt" & Request.QueryString("Filt") does evaluate out to the correct
value.
Thanks,
Keith
It seems that the ID's are fine. When I put me.hypFiltA, or me.hypFiltB, etc
in the watch, they give me a value.
Request.QueryString("Filt") in the watch window returns what I expect: "A"
or "B" or "C" etc.
When I put me.Controls in the watch window, I get a count of 1.
When I put Me.FindControl("hypFilt" & Request.QueryString("Filt")) in the
watch window, it comes up as Nothing.
If I hard code me.hypFiltA in the same event handler, it works fine. The
control exists and I'm able to set its properties. But I don't want to code
all 26 letters of the alphabet into the event handler.
I tried this in other page events as well (preload, init, initcomplete,
loadcomplete, prerender, prerendercomplete... all with same results.
"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:eX**************@TK2MSFTNGP06.phx.gbl...
Set a breakpoint and see if the id is formed correctly, run Me.FindControl
in the watch window, see what is inside the Me.Controls collection. This
should help you to figure out what is going on.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Keith G Hicks" <kr*@comcast.netwrote in message
news:uF**************@TK2MSFTNGP05.phx.gbl...
I'm not sure what I'm doing wrong. Here's my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
Handles Me.Load
Dim hyp As HyperLink = CType(Me.FindControl("hypFilt" &
Request.QueryString("Filt")), HyperLink)
If Not hyp Is Nothing Then
hyp.Font.Bold = True
EndIf
End If
I have several hyperlink controls on a page. Some are ID = hypFiltA,
hypFiltB, hypFiltC, etc. They are used to filter some data by first
letter
of the alphabet. The code runs, nothing crashes but but the code above
never
finds them. hyp always = nothing.
"hypFilt" & Request.QueryString("Filt") does evaluate out to the correct
value.
Thanks,
Keith
"Keith G Hicks" <kr*@comcast.netwrote in message
news:u4**************@TK2MSFTNGP03.phx.gbl...
When I put Me.FindControl("hypFilt" & Request.QueryString("Filt")) in the
watch window, it comes up as Nothing.
If you put Request.QueryString("Filt") in the watch window, what do you see?
If you put "hypFilt" & Request.QueryString("Filt") in the watch window, what
do you see?
Does Me.FindControl("hypFilt" & Request.QueryString("Filt").ToString())
work?
--
Mark Rae
ASP.NET MVP http://www.markrae.net
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:Og**************@TK2MSFTNGP05.phx.gbl...
"Keith G Hicks" <kr*@comcast.netwrote in message
news:u4**************@TK2MSFTNGP03.phx.gbl...
When I put Me.FindControl("hypFilt" & Request.QueryString("Filt")) in
the
watch window, it comes up as Nothing.
If you put Request.QueryString("Filt") in the watch window, what do you
see?
returns "A"
>
If you put "hypFilt" & Request.QueryString("Filt") in the watch window,
what
do you see?
returns "hypFiltA"
Does Me.FindControl("hypFilt" & Request.QueryString("Filt").ToString())
work?
returns Nothing
>
--
Mark Rae
ASP.NET MVP http://www.markrae.net
"Keith G Hicks" <kr*@comcast.netwrote in message
news:Ol**************@TK2MSFTNGP03.phx.gbl...
>If you put Request.QueryString("Filt") in the watch window, what do you see?
returns "A"
>If you put "hypFilt" & Request.QueryString("Filt") in the watch window, what do you see?
returns "hypFiltA"
>Does Me.FindControl("hypFilt" & Request.QueryString("Filt").ToString()) work?
returns Nothing
In which case, it sounds very much like the hypFiltA hyperlink isn't
actually in the Page control container. Might it be contained within another
container within the Page container e.g. an <asp:Panel...?
--
Mark Rae
ASP.NET MVP http://www.markrae.net
No. Like I said in my 2nd post, it's all in a content section. It's a master
page setup (asp.net 2.0 if that helps). This is one of the content pages.
Here's the markup (below the @Page and the @Register Assembly lines):
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2"
runat="Server">
<asp:Image ID="Image1" runat="server"
ImageUrl="~/Images/PageTitles_YearbookPics.jpg" /><br />
<br />
Click an image for a larger view.<br />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
runat="Server">
<br />
<span style="font-size: 11pt">Filters (based on last name at
graduation):</span>
<asp:HyperLink ID="hypFiltAll" runat="server"
NavigateUrl="~/ClassmateYearbookPics.aspx?Filt=ALL" Font-Size="11pt">Show
All</asp:HyperLink>
<asp:HyperLink ID="hypFiltA" runat="server"
NavigateUrl="~/ClassmateYearbookPics.aspx?Filt=A"
Font-Size="11pt">A</asp:HyperLink>
<asp:HyperLink ID="hypFiltB" runat="server"
NavigateUrl="~/ClassmateYearbookPics.aspx?Filt=B"
Font-Size="11pt">B</asp:HyperLink>
etc.....
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:#E*************@TK2MSFTNGP05.phx.gbl...
"Keith G Hicks" <kr*@comcast.netwrote in message
news:Ol**************@TK2MSFTNGP03.phx.gbl...
If you put Request.QueryString("Filt") in the watch window, what do you
see?
returns "A"
If you put "hypFilt" & Request.QueryString("Filt") in the watch window,
what do you see?
returns "hypFiltA"
Does Me.FindControl("hypFilt" & Request.QueryString("Filt").ToString())
work?
returns Nothing
In which case, it sounds very much like the hypFiltA hyperlink isn't
actually in the Page control container. Might it be contained within
another
container within the Page container e.g. an <asp:Panel...?
--
Mark Rae
ASP.NET MVP http://www.markrae.net
"Keith G Hicks" <kr*@comcast.netwrote in message
news:uQ**************@TK2MSFTNGP06.phx.gbl...
[top-posting corrected]
>In which case, it sounds very much like the hypFiltA hyperlink isn't actually in the Page control container. Might it be contained within
another
>container within the Page container e.g. an <asp:Panel...?
No. Like I said in my 2nd post, it's all in a content section. It's a
master
page setup (asp.net 2.0 if that helps). This is one of the content pages.
Here's the markup (below the @Page and the @Register Assembly lines):
OK, just for the sake of clarity, the hyperlinks are all within a content
page, not the MasterPage.
And presumably the code which is trying to refer to those hyperlinks is
similarly behind the content page, not behind the MasterPage...?
--
Mark Rae
ASP.NET MVP http://www.markrae.net
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:e8**************@TK2MSFTNGP06.phx.gbl...
"Keith G Hicks" <kr*@comcast.netwrote in message
news:uQ**************@TK2MSFTNGP06.phx.gbl...
[top-posting corrected]
In which case, it sounds very much like the hypFiltA hyperlink isn't
actually in the Page control container. Might it be contained within
another
container within the Page container e.g. an <asp:Panel...?
No. Like I said in my 2nd post, it's all in a content section. It's a
master
page setup (asp.net 2.0 if that helps). This is one of the content
pages.
Here's the markup (below the @Page and the @Register Assembly lines):
OK, just for the sake of clarity, the hyperlinks are all within a content
page, not the MasterPage.
That's correct.
And presumably the code which is trying to refer to those hyperlinks is
similarly behind the content page, not behind the MasterPage...?
That's correct also.
>
--
Mark Rae
ASP.NET MVP http://www.markrae.net
I am sorry to jump in, but do your hyperlinks have runat=server atribute??
Find control will only work with .NET object.
George.
"Keith G Hicks" <kr*@comcast.netwrote in message
news:Oz**************@TK2MSFTNGP02.phx.gbl...
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:e8**************@TK2MSFTNGP06.phx.gbl...
>"Keith G Hicks" <kr*@comcast.netwrote in message news:uQ**************@TK2MSFTNGP06.phx.gbl...
[top-posting corrected]
>In which case, it sounds very much like the hypFiltA hyperlink isn't actually in the Page control container. Might it be contained within
another container within the Page container e.g. an <asp:Panel...?
No. Like I said in my 2nd post, it's all in a content section. It's a
master
page setup (asp.net 2.0 if that helps). This is one of the content
pages.
Here's the markup (below the @Page and the @Register Assembly lines):
OK, just for the sake of clarity, the hyperlinks are all within a content page, not the MasterPage.
That's correct.
>And presumably the code which is trying to refer to those hyperlinks is similarly behind the content page, not behind the MasterPage...?
That's correct also.
>> -- Mark Rae ASP.NET MVP http://www.markrae.net
Yes. It's in the code I posted a couple of posts up.
"George Ter-Saakov" <gt****@cardone.comwrote in message
news:uw**************@TK2MSFTNGP02.phx.gbl...
I am sorry to jump in, but do your hyperlinks have runat=server atribute??
Find control will only work with .NET object.
George.
Sorry did not see your message...
I've never had a problem with FindControl not working as it suppose to...
So here is my take...
you have a following code which appears to be fine.
Dim hyp As HyperLink = CType(Me.FindControl("hypFilt" &
Request.QueryString("Filt")), HyperLink)
If Not hyp Is Nothing Then
hyp.Font.Bold = True
EndIf
Following options.
0. All you do is set Bold to font. Not sure how Hyperlink control works with
it. The style for <Atag might take over and overwrite the BOLD thing.
Cause it might product folowing html code <B><A>B</A></Bthen style for A
tag will take over the <Btag.
So do something else.
1. Code never executes.... Easy to test in debugger or just add
Response.Write("AAA") right before you do FindCotrol
My bet would be on #0 then #1.
George.
"Keith G Hicks" <kr*@comcast.netwrote in message
news:uV**************@TK2MSFTNGP06.phx.gbl...
Yes. It's in the code I posted a couple of posts up.
"George Ter-Saakov" <gt****@cardone.comwrote in message
news:uw**************@TK2MSFTNGP02.phx.gbl...
>I am sorry to jump in, but do your hyperlinks have runat=server atribute?? Find control will only work with .NET object.
George.
"Keith G Hicks" <kr*@comcast.netwrote in message
news:Oz**************@TK2MSFTNGP02.phx.gbl...
>And presumably the code which is trying to refer to those hyperlinks is similarly behind the content page, not behind the MasterPage...?
That's correct also.
Hmm - OK. I'm starting to run out of options now...
If the code which is trying to reference the hyperlink is definitely behind
the same page where the hyperlink is defined, and the hyperlink is not
contained within a separate container, then FindControl should definitely
find it.
So, can you please try the following:
In the watch window, evaluate Me.Controls.Count and then inspect each of
them e.g.
Me.Controls[0]
Me.Controls[1]
etc
Is hypFiltA one of them...?
--
Mark Rae
ASP.NET MVP http://www.markrae.net
There is only one control. Me.Controls.Count = 1. Me.Control(0) =
{ASP.masterpage_master}. Interesting.
So here's the answer. Ready?
Dim hyp As HyperLink =
CType(Me.Master.FindControl("ContentPlaceHolder1") .FindControl("hypFilt" &
Request.QueryString("Filt")), HyperLink)
This page helped a lot: http://www.west-wind.com/WebLog/posts/5127.aspx
Apparently master pages really screw things up in this regard.
Thanks everyone for all your help.
Keith
There are things I plan to do other than bold. That was my first step. When
I couldn't get that to work I stopped to solve the other problem. Anyway, I
solved it. See my post under Mark's
"George Ter-Saakov" <gt****@cardone.comwrote in message
news:uQ**************@TK2MSFTNGP02.phx.gbl...
Sorry did not see your message...
I've never had a problem with FindControl not working as it suppose to...
So here is my take...
you have a following code which appears to be fine.
Dim hyp As HyperLink = CType(Me.FindControl("hypFilt" &
Request.QueryString("Filt")), HyperLink)
If Not hyp Is Nothing Then
hyp.Font.Bold = True
EndIf
Following options.
0. All you do is set Bold to font. Not sure how Hyperlink control works
with
it. The style for <Atag might take over and overwrite the BOLD thing.
Cause it might product folowing html code <B><A>B</A></Bthen style for A
tag will take over the <Btag.
So do something else.
1. Code never executes.... Easy to test in debugger or just add
Response.Write("AAA") right before you do FindCotrol
My bet would be on #0 then #1.
George.
"Keith G Hicks" <kr*@comcast.netwrote in message
news:uV**************@TK2MSFTNGP06.phx.gbl...
Yes. It's in the code I posted a couple of posts up.
"George Ter-Saakov" <gt****@cardone.comwrote in message
news:uw**************@TK2MSFTNGP02.phx.gbl...
I am sorry to jump in, but do your hyperlinks have runat=server
atribute??
Find control will only work with .NET object.
George. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ivan Demkovitch |
last post by:
Hi!
I have following problem:
When I create control dynamically and assign ID to it it get's changed if
you look at output HTML.
Because I add this control inside ascx it is prefixed with...
|
by: Michael Murschell |
last post by:
If I call Page.FindControl() on an aspx, it finds the control, but if I call
it on an ASCX, it does not. Why not?
And how would I call it?
|
by: Adam Billmeier |
last post by:
Problem:
I am trying to use FindControl to grab a dropdownlist that is in the
EditItemTemplate of a Datalist and then Bind it to a dataset. I also then
need to put the correct values in all of...
|
by: tshad |
last post by:
I am using sample code from C# and am trying to convert it to VB.Net in my
aspx page.
This works in C#:
DataGrid oGrid = (DataGrid)oItem.FindControl("DataGrid1");
I have tried all kinds of...
|
by: Greg Fischer |
last post by:
I need to access the properties of a control that is nested in 2 datalists.
How do you use findcontrol method to do that?
what I have is like this:
<asp:datalist id="dlist" runat="server">...
|
by: Terry Olsen |
last post by:
I've got a datagrid set up to display data. I've also got an
Edit,Update,Cancel column set up to allow editing of data.
I've got a DropDownList (ID="ddl3")in the EditItemTemplate for a certain...
|
by: daniel.hedz |
last post by:
I am generating a usercontrol dynamically successfully, but when I try
to find that usercontrol I get a type mismatch. This is what I am
doing:
//Loading my usercontrol...
|
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= |
last post by:
Hi. I have created a UserControl ("MyUC"). I've put a bunch of instances of
that control on a Page ("Defaul.aspx"). The control works fine.
Now, I want to be able to use "FindControl()" from...
|
by: AAaron123 |
last post by:
Me.FindControl("MissionScheduleID"), below returns null.
Do you know what I'm doing wrong?
Thanks
***In my .aspx file I have:
asp:Content ID="Content3"...
|
by: AAaron123 |
last post by:
I'm this far in determining the correct code to find a textbox I need to
set.
...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |