Reputation: 1184
I have an ASP.NET page with a cs script file to take in data and then post it to another site.
On the site I am using a regular HTML form with asp:TextBox and asp:HiddenField values throughout it to collect/hold data. The problem I'm having is that some of the key data on it have to be hashed and salted before they are posted to a different site.
I have a method to do this, it works fine, but it is attached to the submit button's OnClick attribute, its an asp:Button currently with a postbackurl set. This apparently means that it gets skipped when it goes to the new page which is not what i want.
I'm still fairly new to web development so is there a way to run a method right before the page is submitted, or will I have to run the method everytime a field that would effect the hash is changed ?
Upvotes: 0
Views: 1047
Reputation: 4858
You might want to look at the Page.ClientScript.RegisterOnSubmitStatement
This will be a way to execute some javascript as the form is submitting.
Upvotes: 0
Reputation: 48088
If your hashing method written in javascript and you're calling it at your button's onclick client side event. it should run before your form posted. Using form's onsubmit event might be an alternative.
But if you're talking about server side hashing function that sets the hidden control's value you should use Server.Transfer after your hashing method. Because the button with PostBackUrl property doesn't postback the page itself.
Upvotes: 1