Click button and redirect to new page?

  • Thread starter Miguel Dias Moura
  • Start date
M

Miguel Dias Moura

Hello,

in an ASP.net / VB page i created a form with a button. When the button is
clicked i want to redirect to a new page. I have the following:

....
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<script runat="server">
void goToPage(object sender, System.EventArgs e)
{
Response.Redirect("inscricoes-explicadores-step01.aspx");
}
</script>
<html>
....

and

<asp:Button CssClass="button" ID="iniciar" runat="server" OnClick="goToPage"
Text="Iniciar Inscrição" ToolTip="Click Buttono" Width="140" />

I get this error:

Compiler Error Message: BC30188: Declaration expected.
in line: void goToPage(object sender, System.EventArgs e)

Can you tell me what am i doing wrong and what should i do to fix it?

Thank You,
Miguel
 
N

Natty Gur

Hi,

Your page is VB.NET and you are writing C# or Java script code as server
side block. you should change your server side script to VB.NET.

HTH

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 
J

John Amick

Miguel,

You could easily accomplish this in a simple client-side HTML button with an
onclick event:

<input type="button" value="Click Me!"
onClick="location.href='inscricoes-explicadores-step01.aspx';">

Of course, if you wanted to be able to have dynamic control over the
destination or re-use the code, it would get a bit more complicatied.
Perhaps you could write a control that does the same thing with client-side
script.

-John
 
M

Miguel Dias Moura

That's what i am looking for.

Thanks,
Miguel

John Amick said:
Miguel,

You could easily accomplish this in a simple client-side HTML button with an
onclick event:

<input type="button" value="Click Me!"
onClick="location.href='inscricoes-explicadores-step01.aspx';">

Of course, if you wanted to be able to have dynamic control over the
destination or re-use the code, it would get a bit more complicatied.
Perhaps you could write a control that does the same thing with client-side
script.

-John
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,076
Latest member
OrderKetoBeez

Latest Threads

Top