Hi friends,
I was writing an application to test how I could access web server control
in the client side javascript. I am trying to create a popup which would
contain the value of the button control. The code i wrote is as follows.
the aspx file
<code>
<%@ Page language="c#" Codebehind="StepByStep2_3.aspx.cs"
AutoEventWireup="false" Inherits="_315C02.StepByStep2_3" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>StepByStep2_3</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
function btnSubscribe_ClientClick()
{
alert(document.StepByStep2_3.btnSubscribe.value + " You Suceeded");
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="StepByStep2_3" method="post" runat="server">
<asp:Button id="btnSubscribe" style="Z-INDEX: 101; LEFT: 64px; POSITION:
absolute; TOP: 40px"
runat="server" Text="Button"></asp:Button>
</form>
</body>
</HTML>
</code>
the .aspx.cs file
<code>
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace _315C02
{
/// <summary>
/// Summary description for StepByStep2_3.
/// </summary>
public class StepByStep2_3 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button btnSubscribe;
private void Page_Load(object sender, System.EventArgs e)
{
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnSubscribe.Click += new
System.EventHandler(this.btnSubscribe_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnSubscribe_Click(object sender, System.EventArgs e)
{
btnSubscribe.Attributes.Add("OnClick","btnSubscrib e_ClientClick();");
}
}
}
</code>
What do u think went wrong?
thanks