Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How tro use FindControl (C# or VB)

Reply
Thread Tools

How tro use FindControl (C# or VB)

 
 
Paul
Guest
Posts: n/a
 
      02-24-2006
I have an item in the aspx part of my page:

<a id="PreviousPageNav" runat="server" >

<asp:Image runat=server ID="PreviousImage"
ImageUrl="~/Images/Nav/previous.gif" />

</a>

that I put in the header of a DataList.

When it was outside of the Datalist, on the Code Behind, I accessed it like
this:

PreviousPageNav.HRef = String.Format(navigationFormat, StoreID, pageIndex -
1);

PreviousPageNav.Visible = (pageIndex > 0) ? true : false;



But I can not seem to be able to access it once it is in the header of the
DataList. Looking around, I see the FindControl method, but am usure on how
to use it.

Suggestions, please?



Paul


 
Reply With Quote
 
 
 
 
Nathan Sokalski
Guest
Posts: n/a
 
      02-25-2006
I have never needed to modify the Controls in the HeaderTemplate before, but
I think that you would simply do something like:


YourDataListID.FindControl("PreviousPageNav").HRef =String.Format(navigationFormat,
StoreID, pageIndex-1);


The FindControl(ControlID) method returns a reference to the Control with
ControlID, so you can basically use it in place of where you would normally
just use ControlID. But I have never actually tried this with
HeaderTemplates (although I have with the different ItemTemplates, so I
expect it will be the same), so hopefully it will work. Good Luck!
--
Nathan Sokalski
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/

"Paul" <(E-Mail Removed)> wrote in message
news:K6GLf.5$(E-Mail Removed)...
>I have an item in the aspx part of my page:
>
> <a id="PreviousPageNav" runat="server" >
>
> <asp:Image runat=server ID="PreviousImage"
> ImageUrl="~/Images/Nav/previous.gif" />
>
> </a>
>
> that I put in the header of a DataList.
>
> When it was outside of the Datalist, on the Code Behind, I accessed it
> like this:
>
> PreviousPageNav.HRef = String.Format(navigationFormat, StoreID,
> pageIndex - 1);
>
> PreviousPageNav.Visible = (pageIndex > 0) ? true : false;
>
>
>
> But I can not seem to be able to access it once it is in the header of the
> DataList. Looking around, I see the FindControl method, but am usure on
> how to use it.
>
> Suggestions, please?
>
>
>
> Paul
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use FindControl to find DetailsView BoundField control (vb) sck10 ASP .Net 6 10-24-2011 09:11 AM
Use Viewstate info instead of nested FindControl? John Kotuby ASP .Net 5 12-12-2007 04:34 PM
Trying to use FindControl =?Utf-8?B?TWlrZSBDb2xsaW5z?= ASP .Net 11 12-23-2006 02:46 PM
When need to use FindControl ad ASP .Net 1 04-28-2005 11:21 AM
Use FindControl for HMTL control in Datagrid Sid ASP .Net 4 11-11-2003 09:24 AM



Advertisments