views:

80

answers:

1

I seem to have an issue with using jQuery to do a PostBack.

I can post back no problems but non of my page control values are there.

The code is like this;

WebForm.aspx;

    <script src="/jQueryPlugins/jQuery.Form.js" type="text/javascript"></script>
    <form id="myForm" action="MyForm.aspx" method="post">
        <input type="text" runat="server" id="txtApplicantFirstName" />
    </form>

also

$(document).ready(function() {
    $('#myForm').ajaxForm(function() { alert(99); });
}

Then in my code behind;

protected void Page_Load(object sender, EventArgs e)
{
    string h = txtApplicantFirstName.Value;
}

Why is string h is always empty?

EDIT

I am posting like this in my javascript on the press of an anchor.

$('#myForm').submit();

Edit 2

I just tried the above code in a brand new application and it works. The only difference I can see now is that I am using a master page so the form is in the master page.

A: 

I think I've found it. Can anyone else confirm this behaviour?

The question is still valid, however I have a popup dialog with a button on it. On click of this button I post back and try to get values.

Trouble is that when the dialog displays, I think its markup is moved outside the form which means that the fields are no longer available.

I'm using the modal dialog plugin from here.

So just before I do a submit, I move the whole dialog markup back into the form and I get all my values.

The issue now is that I need to hide the dialog before the jQuery call returns because it all looks a little naff once you move it.

Can anyone else confirm this behaviour or am I again doing someting wrong?

griegs
Thanks @dlamblin. I've fixed the link.
griegs