Dear Martin,
I put the Button2.Attribu tes.Add("onClic k", "doscroll() "); in
webForm2.aspx.c s as below
private void Button2_Click(o bject sender, System.EventArg s e)
{
Button2.Attribu tes.Add("onClic k", "doscroll() ");
}
and in html
<script language="javas cript">
function doscroll(){
x=documen.body. scrollHeight;
x=x+999;
self.scrollTo(0 ,100);}</script>
<h2>
<asp:Button id="Button2" style="Z-INDEX: 101; LEFT: 352px; POSITION:
absolute; TOP: 912px" runat="server" Text="Button"
onClick="doscro ll()"></asp:Button></h2>
after i try to run it...show the error message
"CS0117: 'ASP.WebForm2_a spx' not include 'doscroll' define / declare
"Martin Carolan" <mc******@gmail .com> ¦b¶l¥ó
news:20******** *************@n ews.cable.ntlwo rld.com ¤¤¼¶¼g...
Hello Alan,
What error do you get (if any) when trying that method?
Martin.
i tried it...
but it seems still not work........
"Martin Carolan" <mc******@gmail .com> ¦b¶l¥ó
news:17******** *************@n ews.cable.ntlwo rld.com ¤¤¼¶¼g... Hello Alan,
in your code just add
button1.Attribu tes.Add("onclic k", "doscroll() ");
That should work.
i would like to know how can i use this script in Asp:Button?
thanks
"Martin Carolan" <mc******@gmail .com> ¦b¶l¥ó
news:17******** *************@n ews.cable.ntlwo rld.com ¤¤¼¶¼g...
> Hello Peter,
>
> try this:
>
> <script language="javas cript">
> function doscroll(){
> x=document.body .scrollHeight;
> x=x+99999
> window.scrollTo (0,x);
> }
> </script>
> then in your button's tag add onclick="doscro ll()"
>> You could try using the window.scrollTo () method in JavaScript.
>>
>> "Alan Ho" <gt*********@ya hoo.com.hk> wrote in message
>> news:ui******** ******@TK2MSFTN GP09.phx.gbl...
>>
>>> Cheers~
>>>