By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 2,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

Page load event is not firing.

P: 1
Please help : page load event is not firing.
--------------------------------------------------------------------------------

Hi,
I am a new to .net. I am trying to learn it.
I tried the following code to execute. But the page load event is not firing. I tried , the same function rewriten in C#, then page load event worked absolutely fine.
I dont know why the page load event is not firing in VB.net . Could some one try please try my same code, what I posted here and suggest me what is the wrong in it. I am comfortable with vb6 and classic asp. So I want to learn first ASp.net with vb. I tried some other codes to fire page load event from different books, but effect is same. So please help me.

Many thanks.

My code


<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm5.aspx.vb" Inherits="Myapplication.WebForm5"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>WebForm1</title>
<script language="javascript">
function valSubmit() {
var doc = document.forms[0];
var msg = "";
if (doc.firstName.value == "") {
msg += "- Please enter a first name.n";
}
if (doc.lastName.value == "") {
msg += "- Please enter a last name.n";
}
if (msg == "") {
doc.submit();
return true;
} else {
alert("The following errors were encountered.nn" + msg);
return false;
} }
</script>
<script language="vb" runat="server">
Private sub btnSearch_Click(sender As Object, e As System.EventArgs)
Response.Write("Search")
End Sub
sub Page_Load(sender As Object, e As System.EventArgs)
response.write ("test")
btnSubmit.Attributes.Add("onClick", "return valSubmit();")
End Sub
</script>
</head>
<body>
<form id="frmBuilderTest" method="post" runat="server">
<label style="Z-INDEX: 101; LEFT: 10px; POSITION: absolute; TOP: 48px">
First Name:</label>
<input style="Z-INDEX: 102; LEFT: 88px; POSITION: absolute; TOP: 48px" type="text" name="firstName" id="firstName">
<label style="Z-INDEX: 103; LEFT: 10px; POSITION: absolute; TOP: 88px">
Last Name:</label>
<input style="Z-INDEX: 104; LEFT: 88px; POSITION: absolute; TOP: 88px" type="text" name="lastName" id="lastName"><br />
<br />
<asp:Button id="btnSubmit" style="Z-INDEX: 105; LEFT: 64px; POSITION: absolute;
TOP: 128px" runat="server" Text="Submit" Width="136px" OnClick="btnSearch_Click"></asp:Button>
</form>
</body>
</html>
May 12 '07 #1
Share this Question
Share on Google+
1 Reply


P: 36
Please help : page load event is not firing.
--------------------------------------------------------------------------------

Hi,
I am a new to .net. I am trying to learn it.
I tried the following code to execute. But the page load event is not firing. I tried , the same function rewriten in C#, then page load event worked absolutely fine.
I dont know why the page load event is not firing in VB.net . Could some one try please try my same code, what I posted here and suggest me what is the wrong in it. I am comfortable with vb6 and classic asp. So I want to learn first ASp.net with vb. I tried some other codes to fire page load event from different books, but effect is same. So please help me.

Many thanks.

My code


<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm5.aspx.vb" Inherits="Myapplication.WebForm5"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>WebForm1</title>
<script language="javascript">
function valSubmit() {
var doc = document.forms[0];
var msg = "";
if (doc.firstName.value == "") {
msg += "- Please enter a first name.n";
}
if (doc.lastName.value == "") {
msg += "- Please enter a last name.n";
}
if (msg == "") {
doc.submit();
return true;
} else {
alert("The following errors were encountered.nn" + msg);
return false;
} }
</script>
<script language="vb" runat="server">
Private sub btnSearch_Click(sender As Object, e As System.EventArgs)
Response.Write("Search")
End Sub
sub Page_Load(sender As Object, e As System.EventArgs)
response.write ("test")
btnSubmit.Attributes.Add("onClick", "return valSubmit();")
End Sub
</script>
</head>
<body>
<form id="frmBuilderTest" method="post" runat="server">
<label style="Z-INDEX: 101; LEFT: 10px; POSITION: absolute; TOP: 48px">
First Name:</label>
<input style="Z-INDEX: 102; LEFT: 88px; POSITION: absolute; TOP: 48px" type="text" name="firstName" id="firstName">
<label style="Z-INDEX: 103; LEFT: 10px; POSITION: absolute; TOP: 88px">
Last Name:</label>
<input style="Z-INDEX: 104; LEFT: 88px; POSITION: absolute; TOP: 88px" type="text" name="lastName" id="lastName"><br />
<br />
<asp:Button id="btnSubmit" style="Z-INDEX: 105; LEFT: 64px; POSITION: absolute;
TOP: 128px" runat="server" Text="Submit" Width="136px" OnClick="btnSearch_Click"></asp:Button>
</form>
</body>
</html>
Change AutoEventWireup="false" to AutoEventWireup="true"
Jun 12 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.