3 Replies - 1110 Views - Last Post: 17 January 2013 - 08:29 AM Rate Topic: -----

#1 Xna4life  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 78
  • Joined: 21-February 12

asp:button onClick='navigate + run method'

Posted 17 January 2013 - 08:07 AM

Hi all,

<asp:Button runat="server" ID="Button1" Text="Create" onclick="Create_Click" CssClass="FadeOutOnEdit"/>

This runs the Create_Click method in the aspx.cs page.(Which adds data to the DB)

I would like to run this method and also navigate to a different page when the btn is clicked.
I have been trying:

NavigateUrl="~/Invoices/List.aspx"
ContinueDestinationPageUrl="~/Default.aspx"

any suggestions
Thank ye

Is This A Good Question/Topic? 0
  • +

Replies To: asp:button onClick='navigate + run method'

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9195
  • View blog
  • Posts: 34,516
  • Joined: 12-June 08

Re: asp:button onClick='navigate + run method'

Posted 17 January 2013 - 08:12 AM

Moving to ASP.NET.
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9195
  • View blog
  • Posts: 34,516
  • Joined: 12-June 08

Re: asp:button onClick='navigate + run method'

Posted 17 January 2013 - 08:17 AM

NavigateUrl="~/Invoices/List.aspx"
ContinueDestinationPageUrl="~/Default.aspx"


What are those? String variables? Properties? Where do you think the execution would be if you just set a string variable?

Instead try and look for something that might take action - a method or a function usually, right?

So that being said - the method 'redirect' from the 'response' class typically works best.
Response.Redirect("page3.aspx");

http://msdn.microsof...=vs.100%29.aspx
Was This Post Helpful? 0
  • +
  • -

#4 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1181
  • View blog
  • Posts: 1,675
  • Joined: 24-August 11

Re: asp:button onClick='navigate + run method'

Posted 17 January 2013 - 08:29 AM

You're already doing work in the Create_Click method in code behind, so why go back to the control and try to execute behavior from its attributes? Take modi123_1's solution and add it to the end of the behavior executed by your event handler.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1