span's problem...

S

shimmer

Hi i have this code, which when i click the button ( just an example),
the span doesnt change...Can some1 help me ~ . I am thinking of could
it be the problem of the button. There is no response of the button
event...can anyone give me some advise pls..

<Form Runat="Server">
<Button Id="Button1" Runat="Server"
OnServerClick="Button1_Click">
change</Button><BR>
</Form>
<Span Id="Sp1" Runat="Server">original word</Span>

<Script Language="VB" Runat="Server">
Sub Button1_Click(Sender As Object, e As Eventargs)
Sp1.InnerHtml="<B>CHANGED!!</B>"
End Sub
</Script>
 
S

Scott M.

Yes, your code is a bit mixed up. You don't add the OnServerClick attribute
to the <Button> tag. By marking as runat=server, you simply create the
correct server event handler for the button and don't forget the "Handles"
clause as I've shown.

By the way, why use an HTML server control rather than an ASP.NET Server
Control (<ASP:Button>)?

Sub Button1_Click(sender as object, e as eventArgs) Handles
Button1.ServerClick

End Sub

shimmer said:
Hi i have this code, which when i click the button ( just an example),
the span doesnt change...Can some1 help me ~ . I am thinking of could
it be the problem of the button. There is no response of the button
event...can anyone give me some advise pls..

<Form Runat="Server">
<Button Id="Button1" Runat="Server"
OnServerClick="Button1_Click">
change</Button><BR>
</Form>
<Span Id="Sp1" Runat="Server">original word</Span>

<Script Language="VB" Runat="Server">
Sub Button1_Click(Sender As Object, e As Eventargs)
Sp1.InnerHtml="<B>CHANGED!!</B>"
End Sub
</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

Top