Reputation: 5800
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
Upvotes: 0
Views: 120
Reputation: 1075039
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:
Pass it as a query string parameter to the new page.
Save it as a cookie and have the subsequent page read the cookie.
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.
Upvotes: 2