0

I have an html form with hidden values empty like below

<body>
<form runat="server" id="PostToMPI" name="PostToMPI" method="post" action="https://www.e-tahsildar.com.tr/V2/NetProvOrtakOdeme/NetProvPost.aspx" >

    <asp:HiddenField ID="pHashB64" runat="server" Value="" />
    <asp:HiddenField ID="pHashHex" runat="server" Value="" />

    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</form>

in the c#

protected void Button1_Click(object sender, EventArgs e)
{
   pHashB64.Value = "calculated value";
   pHashHex.Value = "calculated value";
}

it is using post method. when the user clicks the button, I am calculating the values set them to the hidden fields.

I am wondering if it submits the form before it sets the hidden fields? I mean that I am posting with empty fields?

thank you

1 Answer 1

1

When you specify action attribute in form tag, it transfers your request to that URL instead of firing postback in the same page and executing button click event.

Rather you can use querystring method whose URL will be generated in button click event and redirecting to the URL set in action attribute.

<form runat="server" id="PostToMPI" name="PostToMPI" method="post" >

<asp:HiddenField ID="pHashB64" runat="server" Value="" />
<asp:HiddenField ID="pHashHex" runat="server" Value="" />

<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.