JScript / JavaScript Help

R

Roshawn Dawson

Hi,

Could someone tell how to force a mouse event using either jscript or
javascript? I simply want to allow users to scroll the page after
postbacks using the scroll button on either a mouse or the keyboard
without them having to click the page first.

Thx,
Roshawn
 
K

Ken Cox [Microsoft MVP]

Hi Roshawn,

The simplest way is to make sure that a control on the page has the focus
after the page is loaded. In the sample below, I give the textbox a tabindex
and in the codebehind, I emit the Javascript to cause the textbox to have
the focus.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
Toronto

<form id="Form1" method="post" runat="server">
<p>
<asp:textbox TabIndex="0" id="TextBox1"
runat="server"></asp:textbox></p>
<p>
<asp:button id="Button1" runat="server"
Text="Button"></asp:button></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>
<asp:hyperlink id="HyperLink1"
runat="server">HyperLink</asp:hyperlink></p>
</form>

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Page.RegisterStartupScript("startup", _
"<script>TextBox1.focus();</script>")
End Sub
 

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

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top