kullanarak asp.net'den nasıl oturum geri gelebilirim Jquery'yi kullanarak a.aspx'te depolanan oturum değişkenini nasıl alabilirim? Oturumda kayıtlı kullanıcı adı var, menü çubuğunda kullanıcı adını görüntülemek için oturumu geri almam gerekiyor. A.aspx üzerinden giriş yapan bir kişi ve onun ayrıntıları (veritabanından) B.aspxJquery
Q
Jquery
0
A
cevap
1
'da görüntülenmelidir. Bunu işlemenin bir yolu, geçerli sayfanızda bir Web Yöntemi veya benzeri oluşturmaktır. AJAX çağrı yoluyla Oturum güncellenmiş değeri:
Sonra[WebMethod]
public static string GetSessionValue(string key)
{
return Session[key];
}
Eğer gerekli spesifik anahtar istemek için AJAX üzerinden POST
çağrı yapabilir (veya herhangi bir parametre ve basitçe sabit kod anahtarı ihmal etmesi Metodun kendisi içinde çekmek istediniz):
public static string GetSessionDisplayName()
{
// Use the name of your Session key here to retrieve your info
return Session["DisplayName"];
}
Ve sonra bir parametre ile çekin için aşağıdaki jQuery kodu kullanabilirsiniz:
$.ajax({
type: "POST",
url: "YourPage.aspx/GetSessionValue",
data: '{ key: "your-session-key" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
// data will hold your Session value, use it here
alert(data);
}
});
Veya bir olmadan:
$.post('YourPage.aspx/GetSessionDisplayName',function(data){
// data will hold your Session value, use it here
alert(data);
});
İlgili konular
- 1. jQuery - jquery
- 2. jquery - jquery ile
- 3. Jquery JQuery UI
- 4. JQuery
- 5. jQuery
- 6. jQuery
- 7. jQuery
- 8. jQuery:
- 9. jQuery
- 10. jquery
- 11. JQuery
- 12. jQuery,
- 13. jQuery
- 14. JQuery
- 15. jQuery -
- 16. jQuery
- 17. jQuery
- 18. jQuery
- 19. jQuery,
- 20. Jquery
- 21. jQuery
- 22. jQuery
- 23. jquery
- 24. jQuery
- 25. jquery
- 26. jQuery
- 27. jquery
- 28. jquery
- 29. jquery
- 30. jQuery