Originariamente inviato da FiOrEbAt
mah, mi sembra concettualmente sbagliatuccio, serve un post-back, cioè, devi fare il submit della form per passare al server il valore dei controlli!
così avrei risposto pure io :master: comunque, come esempio ecco una pagina
codice:
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim platform As String = Me.Request.QueryString("platform")
If Not (String.IsNullOrEmpty(platform)) Then
Me.Session("platform") = platform
End If
If Me.Session("platform") Is Nothing Then
Me.ClientScript.RegisterStartupScript(Me.GetType, "invio_platform", "var img = new Image(); img.src = ""?platform="" + encodeURIComponent(window.navigator.platform);", True)
End If
End Sub
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If Me.Session("platform") IsNot Nothing Then
Me.Label1.Text = CStr(Me.Session("platform"))
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Pagina senza titolo</title>
</head>
<body >
<form id="form1" runat="server">
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Serve per verificare che la variabile platform sia stata inviata al server</asp:LinkButton>
<asp:Label ID="Label1" runat="server" Text="" EnableViewState="false"></asp:Label>
</form>
</body>
</html>
:quote: Penso che sia più utile studiare l'html prodotto sia la prima volta, sia dopo aver premuto il linkbutton.