RockOn
RockOn

Reputation: 197

Best way to add button navigation (linkable buttons) in ASP.Net?

I already tried the obvious of adding ASP.Net buttons, but it completely throws off any pages with forms.

<asp:Button ID="ButtonAddEvents" runat="server" Text="Add Events" class="navbutton" onclick="ButtonAddEvents_Click"  />

C#:

protected void ButtonAddEvent_Click(object sender, EventArgs e)
{
    Response.Redirect("addevent.aspx");
}

I have tried a JavaScript button but same result occurs where it doesn't agree with pages with forms:

<button class="navbutton" onclick="window.location='addevent.aspx';">Add Event</button> 

What is the best way to add a button with a link on a page in Visual Studio?

Upvotes: 2

Views: 2307

Answers (1)

Mike
Mike

Reputation: 807

that shouldn't be happening,

a response redirect or changing the document or window location would redirect you anywhere you want' are you sure you want a response redirect, or you want a post?

if your redirecting is failing that means your other ASPX page is not working

the best option for a link is to use the href the other options is writing a button with a redirect just like you did

are you sure your application is redirecting to the correct page

try to use a "/" and always start from the root directory

for example is your page is on www.mypage.com/browse/start.aspx

your redirect link should look like :"/browse/start.aspx"

Upvotes: 1

Related Questions