How to set form action attribute

I just upgraded an ASP.NET application from .NET 3.5 to 4.0. One of the violation of changes is the attribute of the form action empty when navigating the root folder instead of automatically automatically selecting default.aspx.

Matching the action attribute in the markup or in the code does not work, because the action attribute is still empty when the page is displayed.

Markup: <form id = "MyForm" runat = "server" action = "default.aspx">

Code: Me.Page.Form.Action = "default.aspx"

Using jQuery to add an action to a finished event really works.

$(document).ready(function() { $('#MyForm').attr("action","default.aspx"); }); 

Is there any other solution?

+1
Jan 24 '12 at 23:00
source share
1 answer

You should try: $ ('form'). get ('MyForm'). setAttribute ('action', 'default.aspx');

0
May 9 '12 at 14:13
source share
— -



All Articles