Reputation:
How to change the Form Action and Form id at run time. the form tag implemented on master page. please give any solution?
Upvotes: 2
Views: 1244
Reputation: 25214
Sounds like you need to use JavaScript. You can do it as follows:
<script>
var myForm = document.getElementById("oldFormId");
myForm.action = "newAction";
myForm.id = "newFormId";
<script>
Note that this will only change the id and action of the form on the given page and will not affect your actual code (because it is a client-side change). If you wanted, you could encapsulate this logic in a function which is included in your master page itself, which would make it accessible from anywhere on the site.
Upvotes: 1
Reputation: 22619
Try this
Page.Form.ID = "newFormId";
Page.Form.Action = "NewPage.aspx";
Note: Used ASP.Net 4.0, Have no idea about previous versions will it work
Upvotes: 1