I am relatively new to ASP.NET & ASPX. I'm getting there slowly but surely...
I've got this code and what it does is simply display a pop-up that consists of 2 images, a background and a clickable image(button). The idea is that when the user clicks on the button, it displays their user id. The setup is just javascript & HTML within in an ASPX file (so that it can actually read the user's id etc). When i do a 'response.write' in the .NET section, it displays the user's ID on the screen no problem. However, my problem is that the javascript can't see 'userid', so when i do an 'alert(userid) in javascript, it doesn't actually display the ID, its just blank.
Heres my code:
<%@ Import Namespace="dbfunctions"%>
<%@ import Namespace="generalfunctions" %>
<%@ Import Namespace="system.data" %>
<script language="VB" runat="server">
sub Page_Load(Sender as Object,e as EventArgs)
Dim userid As Integer
Dim rst As DataView
Dim connstr As String = getStrConn(HttpContext.Current)
userid = Session("u_id")
connstr = getStrConn(HttpContext.Current)
response.write(userid)
End Sub
</script>
<script type='text/javascript'>
function loadPage(){
alert(userid)
}
</script>
<html>
<head>
<title>Please update your details</title>
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
<img id="img" src="corkboard.png"/>
<a id="b1" href="#" onclick="loadPage()"><img src="button.png" style="border-style: none"/></a>
</body>
</html>
Any help is greatly appreciated as I think i'm almost there, the aspx & javascript individually work, its just a matter of bringing them together...
Many thanks :).
Aucun commentaire:
Enregistrer un commentaire