Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

Scrolling to a specific control.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mufasa - 17 Mar 2008 16:53 GMT
I have a control on a page that appears when there's something somebody
needs to enter. No problem - part of a panel and when they need to enter
into it, I set the focus for the control. Problem is, it's not on the page.
How can I get the control to be on the page when the page reloads?

TIA - Jeff.
Mark Rae [MVP] - 17 Mar 2008 17:20 GMT
>I have a control on a page

> Problem is, it's not on the page.

You have a control on a page, but the problem is that it's not on the
page...?

Please clarify...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

David Wier - 17 Mar 2008 17:51 GMT
If you are creating the control dynamically, make sure it gets created each
time the page reloads
If you're talking visiblity, then, just make sure the control or panel in
which it's contained is visible, based on the event handler necessary for
this.

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup

>I have a control on a page that appears when there's something somebody
>needs to enter. No problem - part of a panel and when they need to enter
>into it, I set the focus for the control. Problem is, it's not on the page.
>How can I get the control to be on the page when the page reloads?
>
> TIA - Jeff.
Mufasa - 17 Mar 2008 18:05 GMT
OK everybody - let me try this again:

I've got a control that isn't visible all the time - it's in a panel. When
the user clicks a button, I make the panel visible and I want to scroll to a
control on the panel. I can set the focus to the control but that doesn't
scroll to the control. I've tried setting
Page.MaintainScrollPositionOnPostBack = true;  but that just scrolls back to
the place it was before - not to the control I need it to go to.

Any ideas?

TIA - Jeff.

> If you are creating the control dynamically, make sure it gets created
> each time the page reloads
[quoted text clipped - 13 lines]
>>
>> TIA - Jeff.
George Ter-Saakov - 17 Mar 2008 18:49 GMT
Use Javascript's function .focus();. It will scroll control into visible
portion of the screen.

Something like this
var obj = document.getElementById('myid');
obj.focus();

George.

> OK everybody - let me try this again:
>
[quoted text clipped - 26 lines]
>>>
>>> TIA - Jeff.
Mufasa - 17 Mar 2008 19:42 GMT
Great. Thank you. When I have a .Net control, the name get's changed as the
page is loaded so that something that is tbPersonsName becomes something
weird like tbPersonsName_ctl100. If I'm going to write javascript code to
find that control, I need to know the name of the control as it actually
appears on the page. How do I find out the name on the page rather than what
I've called it in code?

TIA - Jeff.

> Use Javascript's function .focus();. It will scroll control into visible
> portion of the screen.
[quoted text clipped - 35 lines]
>>>>
>>>> TIA - Jeff.
Mark Rae [MVP] - 17 Mar 2008 19:50 GMT
[top-posting corrected]

> Great. Thank you. When I have a .Net control, the name get's changed as
> the page is loaded so that something that is tbPersonsName becomes
> something weird like tbPersonsName_ctl100. If I'm going to write
> javascript code to find that control, I need to know the name of the
> control as it actually appears on the page. How do I find out the name on
> the page rather than what I've called it in code?

document.getElementById('<%=MyControl.ClientID%>').focus();

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Mufasa - 18 Mar 2008 13:22 GMT
I don't think that helps me. I still don't know the actual name of the
control since it's been changed by .Net.

> [top-posting corrected]
>
[quoted text clipped - 6 lines]
>
> document.getElementById('<%=MyControl.ClientID%>').focus();
George Ter-Saakov - 18 Mar 2008 13:28 GMT
That is what <%=MyControl.ClientID%> for.
It will output the actual Control Id.
Obviously MyControl is your controls' name. ClientID is a property any .NET
control have

George.

>I don't think that helps me. I still don't know the actual name of the
>control since it's been changed by .Net.
[quoted text clipped - 9 lines]
>>
>> document.getElementById('<%=MyControl.ClientID%>').focus();
Mark Rae [MVP] - 18 Mar 2008 14:05 GMT
[top-posting corrected again]

>>> Great. Thank you. When I have a .Net control, the name get's changed as
>>> the page is loaded so that something that is tbPersonsName becomes
[quoted text clipped - 7 lines]
>I don't think that helps me. I still don't know the actual name of the
>control since it's been changed by .Net.

That's what <%=MyControl.ClientID%> is for...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.