0

I have a function written on some another page load event.i want to open new page and write content (such as textbox value) to newly opened page

function updateUser() {
    $("button").on("click", function () {
        var code = $(this).attr('id');        
        $.ajax({
            url: '/ajaxExecute.aspx?Fn=GETUSERFORUPDT',
            type: 'POST',
            context: document.body,
            data: 'Code=' + code,
            cache: false,
            success: function (response) {
                if (response != 'undefined') {
                    window.location = 'AddEditUser.aspx';
                    $('#txtUserName').val(response.split("|")[0]);                    
                }                
            }
        });
    });
}

Textbox with id txtUserName lies in page AddEditUser.aspx & function updateUser() load in another .aspx page

My Page loads but not able to get value in textbox as i am able to get value using alert()

I refer this links but still cudnt figure out

Write Content To New Window with JQuery

New window with content from modal content on opener page

1
  • window.location = 'AddEditUser.aspx?value=response.split("|")[0]'; use like this . In AddEditUser.aspx page use query string to get value Commented May 28, 2013 at 12:36

1 Answer 1

2

If you mean (as you seem to from the sample code) that you want to open a new page in the same window and then write the value to a textbox on that page afterward, you can't do that.

Alternatives:

  1. Pass it as a query string parameter to the new page.

  2. Save it as a cookie and have the subsequent page read the cookie.

  3. Save it in local storage (which is a lot like the cookie option).

I can think of a couple of other options, but what all of these have in common is that they require that the receiving page do something. There's no way to drive this from the sending page alone.

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.