Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Re: asp.net server controls


Message #1 by "Ben Sanchez" <eljami@h...> on Thu, 1 Aug 2002 08:00:35
Hello arlon...

Here you go!...I hope you can help me! :)


<script runat="server" language="C#">
  void Page_Load()
 {
   Message1.Text= "";
   Message2.Text= "";
   Message3.Text= "";
  
   if (text1.Text != ""){
	Message1.Text= "You have entered the following name: " + 
text1.Text;

}

   if (text2.Text != ""){
	Message2.Text= "You have entered the following address: " + 
text2.Text;

}

   if (text3.Text != ""){
	Message3.Text= "You have entered the following password: " + 
text3.Text;

}

}
</script>
<html>
    <head>
       <title> Text Box Example</title>
    </head>
    <body>
       <asp:Label id="Message1" runat="server" />
       <br />
       <asp:label id="Message2" runat="server" />
       <br />
       <asp:label id="Message3" runat="server" />
       <br />
     <form runat="server">
        Please enter your name:
       <asp:textbox id="text1" runat="server" />
       <br />
        Please enter your address:
       <asp:textbox id="text2" runat="server" rows=5 
textmode="multiline" />
       <br /><br />
       Please enter your chosen password:
       <asp:textbox id="text3" runat="server" textmode="password" />
       <br /><br />
       <input type="Submit">
     </form>
   </body>
</html>


AND




<script runat="server" language="C#">
    void Page_Load(Object sender, EventArgs e)
    {  
  string msg = "You have selected: <br />";

      if (list1.Items[0].Selected) {
    msg = msg + list1.Items[0].Text + "<br />";
  } 
        if (list1.Items[1].Selected) {  
     msg = msg + list1.Items[1].Text + "<br />";
  } 
        if (list1.Items[2].Selected) {
    msg = msg + list1.Items[2].Text + "<br />";
  }
     Message.Text = msg;
    }
</script>
<html>
  <head>
    <title>Drop Down List Example</title>
  </head>
  <body>
    <asp:label id="Message" runat="server"/> 
    <br />
    <form runat="server">
    Which city do you wish to look at hotels for?<br /><br />
    <asp:listbox id="list1" runat="server" selectionmode="multiple">
      <asp:listitem>Madrid</asp:listitem>
      <asp:listitem>Oslo</asp:listitem>
      <asp:listitem>Lisbon</asp:listitem>
    </asp:listbox>
    <br /><br /><br /><br />
    <input type="Submit">
    </form>
  </body>
</html>


> Hi, Ben!

> Could you post a copy of the code you have in the book? Unfortunately, 
I 
d> on't have a copy so I think it would help if you post is here on the 
web.

> Thanks!

> Regards,
M> arlon

> 
>>  
I>  am doing the sample problems for Chapter 3.  BookBeginningASP.NET 1.0 
w> ith C# (ASP.NET v1.0) and I cant' getthedropdownlist and listbox 
control 
t> o work(page 104 and 110) (l I can see the form displayed in my browser 
b> ut the labelcontrolwill not display what I select from the 
dropdownlist 
n> orthelistbox. Any suggestions?
 > 
T> hank youSend and receive Hotmail on your mobile device: Click Here

  Return to Index