how do i set focus

  • Thread starter Thread starter bob
  • Start date Start date
B

bob

I have a very long web page with several datagrids.
there are pushbuttons on the top for various functions.
One of them is to bring you to the last datagrid (the
bottom) on the page.

what is the function that will allow me to set the focus
onto a datagrid on the same web page (similar to using <a
href=#label> in html world).

I'm using a pushbutton to keep the look the same as the
rest of the buttons in place of a link button.

bob
 
Hi

Put the ID of the DG as a parameter to the moveFocus fucntion
<button onclick="moveFocus('sElementID_To_Focus_On')">

function moveFocus(sElementID){
var e = null;
if(document.getElementById) e = document.getElementById(sElementID);
else if (document.all) if(document.all[sElementID]) e =
document.all[sElementID];
if(e!=null ) if(e.scrollIntoView) e.scrollIntoView(true);
}

--
Best Regards
Vidar Petursson
==============================
Microsoft Internet Client & Controls MVP
==============================
 
I have pasted your code into the head of the html code on my webform.
in the code behind module I have:

FindBtn.Attributes("OnClick") = "javascript:
movefocus('SelectTransGrid')"

however it does not move to that datagrid. I have tried it with the
button causing and not causing validation. am I missing something????





script that was pasted in the head of the html stuff:

<SCRIPT LANGUAGE="javascript">
function moveFocus(sElementID){var e = null;if(document.getElementById)
e = document.getElementById(sElementID);else if (document.all)
if(document.all[sElementID]) e =document.all[sElementID];if(e!=null )
if(e.scrollIntoView) e.scrollIntoView(true);}
</SCRIPT>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top