I have a quandary.
I am working through Apressâ book Moving to ASP.NET: Web Development With VB .NET
, and I have been taking SkillSoft online courses, reading the posts here (and answering some). After all of that, I got the idea that clicking a server control button submits the pageâs form, and resends the page to the browser.
Upon experimentation, I see that this is true.
When I click on a server control button, IEâs globe starts spinning, and it keeps spinning while the server-code is paused.
When I let the server proceed, the web page is sent to the browser all over again. Ie, the text-box has its original value all over again.
Apparently if you want to use server-side code for buttons and such, you need to take the state of the controls, and echo that back to the browser.
(It seems that this in turn will modify what each controlâs âdefaultValueâ is, but that's not a âshow-stopper.â)
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="test_events.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<body MS_POSITIONING="GridLayout" bgColor="#b9e9ff">
<form id="Form1" method="post" runat="server">
style="Z-INDEX: 10; LEFT: 98px; POSITION: absolute; TOP: 50px"
runat="server" Width="160px" Height="32px"
Text="From Web Forms Sect."></asp:Button>
style="Z-INDEX: 20; LEFT: 98px; WIDTH: 160px; POSITION: absolute; TOP: 90px; HEIGHT: 24px"
type="text" size="21" value="Box 1">
I put a breakpoint in Sub WbFrms_Sect_Btn_Click() to examine the environment, and ran it.
Sure enough, if I change the contents of the text box, when I click WbFrms_Sect_Btn the breakpoint is triggered (with IEâs globe spinning around). When I let the code finish, the textbox gets it original value put back into it.
If I want to run a click event (or whatever) through the auspices of a server control, how do I maintain the values in the controls that the user has thus far modified?
BTW: I tried to examine the value in the textbox with Request.Form("Box1") to no avail. Thimble, thimble: Where is the thimble? (Where is
Also, If I donât want to use data binding for the value of a given control (letâs just say a textbox for simplicityâs sake), how do I dynamically set its value?
I am a skilled VB6 Webclass programmer, but Iâm having a little trouble with understanding how to accomplish things that I know can be done, in this new environment.