-3

I am new to the javascript/aspx world and most of my programming was done through trial and error and lots of internet searching, but i've hit upon a problem i cannot find a solution for.

I have a popup page that has 2 input boxes, and i have managed to add default values to both of these input boxes, for dates, like so:

    $(window).load(function () {
    var now = new Date();
    var month = (now.getMonth() + 1);
    var day = now.getDate();
    if (month < 10)
        month = "0" + month;
    if (day < 10)
        day = "0" + day;

    $('#FNewDate').val('01/' + month + '/' + now.getFullYear());

    $('#TNewDate').val(day + '/' + month + '/' + now.getFullYear());
    }     

now, if the user has entered a new date and hits the submit button, the page posts and reloads with the calculated results displayed to the user AND THE DEFAULT VALUES again, but not with the new dates the user has entered, and i need it to stay with the entered information.

I have tried playing around with static members but i have not been able to get it to work.

Here is the button action:

<asp:Button ID = "Calculate" runat = "server" 
                style="width:40% ; font:15px arial" Text = "Calculate" onclick="Calculate_Click" />

any help on the above would be appreciated, and pls include code in your replies...

Thnks

1 Answers1

0

You should change your default value setters to add

if ($('#FNewDate').val().length() != 0)

To only set the value in case the value coming from server is empty.

Then in your input

<input type="text" id="FNewDate" value="<%=someObject.getSomeDate()%>"/>
Rubén
  • 524
  • 5
  • 22
  • thank you for the reply. unfortunately i dont know enough to be able to apply it, for example, where does the someObject.getSomeDate() reside. would you be able to walk me through this? – Hood's Gate Apr 15 '13 at 09:05
  • When you submit the form, that information goes to the server as POST or GET right? Then you get it like this http://stackoverflow.com/questions/976613/get-post-data-in-c-asp-net In this thread they also have examples on how to print server vars – Rubén Apr 15 '13 at 09:19
  • Ahh, managed to get it to work with a little schmoozing of the code to check static members on the C# side of the page. Thank you very much Khanser, that was extremely helpful – Hood's Gate Apr 15 '13 at 09:53