I try to save on Onclientclick to my hiddenfield a string value but it doesnt work I think because of Server.Transfer();
In my is only one control for postback(Dropdownlist) if I change dropdown value I get work Server.Transfer at last in my code.
Here is the code :
$(document).ready(function () {
alert($("[id*=hdnSelectedDiv]").val());
});
function SaveDiv(value) {
$("[id*=hdnSelectedDiv]").val(value);
}
<asp:LinkButton runat="server" CssClass="card-link" ID="lnkGoToLogin" OnClientClick="SaveDiv('dvLogin');return false;" meta:resourcekey="lnkGoToLoginRes"></asp:LinkButton></p>
Here is my OnSelectedIndexChanged :
CurrentSession.SetCurrentLanguage(ddl.SelectedValue);
ddl.SelectedValue = CurrentSession.CurrentLanguage.IetfLanguageTag;
Thread.CurrentThread.CurrentCulture = new CultureInfo(ddl.SelectedValue);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(ddl.SelectedValue);
Server.Transfer(Request.Url.AbsolutePath);
On document ready alert is my value always empty.I try to set value on my document and alert the value it is working.but if I click linkbutton and select any option in my dropdown after postback is my value empty.
How can I solve this I dont want to use Response.Redirect();
That hidden field must have name
property.
When the postback occurs, within the server code, is the moment when you can retrieve posted values. This is the time to process them - because, after Server.Transfer
starts executing, source context is gone. If you need those values within the target request (the handler transferred to), you need to pass them to it. Your options are: persisted storage (e.g. database), session (might be the best in your case), query.