[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

asp.net 1.1 event handlers

Posted on 2011-10-23
3
Medium Priority
?
275 Views
Last Modified: 2012-05-12
Hi

How to debug asp.net 1.1 application. I worked on asp.net 2.0 and later but not with asp.net 1.1 in VS 2003. I just placed button and textbox on ui and in button click handler, i am assigning random text. But when i select the button, i am seeing blank page. why so?  what is different in running asp.net 1.1 and 2.0

below is code.

-------------------------------
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication2.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
      <HEAD>
            <title>WebForm1</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">
      </HEAD>
      <body MS_POSITIONING="GridLayout">
            <form id="Form1" method="post" runat="server">
                  <asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 200px; POSITION: absolute; TOP: 120px"
                        runat="server"></asp:TextBox>
                  <asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 248px; POSITION: absolute; TOP: 216px" runat="server"
                        Text="Button"></asp:Button>
            </form>
      </body>
</HTML>

--------------------------
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 WebApplication2
{
      /// <summary>
      /// Summary description for WebForm1.
      /// </summary>
      public class WebForm1 : System.Web.UI.Page
      {
            protected System.Web.UI.WebControls.TextBox TextBox1;
            protected System.Web.UI.WebControls.Button Button1;
      
            private void Page_Load(object sender, System.EventArgs e)
            {
                  // Put user code to initialize the page here
            }

            #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.Button1.Click += new System.EventHandler(this.Button1_Click);
                  this.Load += new System.EventHandler(this.Page_Load);

            }
            #endregion

            private void Button1_Click(object sender, System.EventArgs e)
            {
                  TextBox1.Text="foo";
            }
      }
}


Thank You,
Naresh
0
Comment
Question by:sangeetaandkarthik
3 Comments
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 37015929
Button click event causes postback. At that time the page load event is called. In page load event the text is not being set. Hence you are not able to see the value. Use the code to set the value correctly.

You can use some other options as well such as setting value in client side using Javascript and EnableViewState=true to the textbox control.

private void Page_Load(object sender, System.EventArgs e)
   {
       if(Page.IsPostBack)
       {
           TextBox1.Text="foo";
       }

    }

Open in new window

0
 
LVL 7

Accepted Solution

by:
kovilpattiBalu earned 2000 total points
ID: 37017633
hi,

In IIS change the virtual directory framework to point to 2.0.50707 in ASP.net tab.
0
 
LVL 10

Expert Comment

by:GlobaLevel
ID: 37018402
in addition to the above, I was also expecting, an on_click in your asp tag:

chage this :
       <asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 248px; POSITION: absolute; TOP: 216px" runat="server"
                        Text="Button"></asp:Button>

to this:

       <asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 248px; POSITION: absolute; TOP: 216px" runat="server"
                        Text="Button" OnClick="Button1_Click" ></asp:Button>


to reference this in your code behind:
        private void Button1_Click(object sender, System.EventArgs e)
            {
                  TextBox1.Text="foo";
            }
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month19 days, 11 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question