SlideServe
Menu
Préférences
© SlideServe · v2026

Web Controls

chick avatar
11 diapositives · 283 Views · Oct 09, 2014

Web Controls. Making a WebRequest. using System; using System.Collections.Generic ; using System.Linq ; using System.Text ; using System.Net ; using System.IO;. Creating a WebRequest. namespace WebRequestorApp { class Program { static void Main( string [] args ) {

Web Controls - slide 1
01 / 11Web Controls
1 / 17

Télécharger la présentation

Web Controls
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Web Controls

  2. Making a WebRequest using System; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; usingSystem.Net; using System.IO;

  3. Creating a WebRequest namespaceWebRequestorApp { classProgram { staticvoid Main(string[] args) { WebRequestreq = WebRequest.Create("http://www.microsoft.com"); WebResponseresp = req.GetResponse(); StreamReader reader = newStreamReader(resp.GetResponseStream(), Encoding.ASCII); Console.WriteLine(reader.ReadToEnd()); } } }

  4. Mixing Code With HTML <%@PageLanguage="C#"Debug="true" %> <html> <body> <h1>Hello World!!!</h1> <% // This block will execute in the Render_Control method Response.Write("Check out the family tree: <br/> <br/>"); Response.Write(this.GetType().ToString()); Response.Write(" which derives from: <br/> "); Response.Write(this.GetType().BaseType.ToString()); Response.Write(" which derives from: <br/> "); Response.Write(this.GetType().BaseType.BaseType.ToString()); Response.Write(" which derives from: <br/> "); Response.Write( this.GetType().BaseType.BaseType.BaseType.ToString()); Response.Write(" which derives from: <br/> "); Response.Write( this.GetType().BaseType.BaseType.BaseType.BaseType.ToString()); %> </body> </html>

  5. Mixing Code With HTML :Server Side <%@PageLanguage="C#"Debug="true" %> <scriptrunat="server"> voidShowLineage() { Response.Write("Check out the family tree: <br/> <br/>"); Response.Write(this.GetType().ToString()); Response.Write(" which derives from: <br/> "); Response.Write(this.GetType().BaseType.ToString()); Response.Write(" which derives from: <br/> "); Response.Write(this.GetType().BaseType.BaseType.ToString()); Response.Write(" which derives from: <br/> "); Response.Write( this.GetType().BaseType.BaseType.BaseType.ToString()); Response.Write(" which derives from: <br/> "); Response.Write( this.GetType().BaseType.BaseType.BaseType.BaseType.ToString()); } </script> <html> <body> <h1>Hello World!!!</h1> <% ShowLineage(); %> </body> </html>

  6. Dropdown List <formid="form2"runat="server"> <divstyle= "font-family: 'Times New Roman', Times, serif; font-size: 14pt; font-weight: bold"> Page in Visual Studio<br/> <asp:LabelID="Label1"runat="server"Text="Type in me:"></asp:Label> <asp:TextBoxID="TextBox1"runat="server"></asp:TextBox> <br/> <asp:DropDownListID="DropDownList1"runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> <asp:ListItem>Item 4</asp:ListItem> <asp:ListItem>Item 5</asp:ListItem> <asp:ListItem>Item 6</asp:ListItem> </asp:DropDownList> <br/> <asp:ButtonID="Button1"runat="server"Text="Click Me"/> </div> </form>

  7. DropDownList Code protectedvoid Button1_Click(object sender, EventArgs e) { Response.Write("Hello. Here's what you typed into the text box: <br/>"); Response.Write(this.TextBox1.Text); Response.Write("<br/>"); Response.Write("And the selected item is: <br/>"); Response.Write(this.DropDownList1.SelectedItem.Text); }

  8. CheckBoxList protectedvoidButton1_Click(objectsender,System.EventArgs e) { Label1.Text = "You Selected:<br/>"; foreach (ListItem li in CheckBoxList1.Items){ if (li.Selected == true){ Label1.Text += li.Text + "<br/>"; } } }

  9. RadioButtonList <formid="form2"runat="server"> <divstyle="text-align: left"> <br/> My level of education is:<asp:RadioButtonListID="RadioButtonList1" runat="server"AutoPostBack="True" onselectedindexchanged="RadioButtonList1_SelectedIndexChanged"> <asp:ListItem>Primary school</asp:ListItem> <asp:ListItem>Middle school</asp:ListItem> <asp:ListItem>High School</asp:ListItem> <asp:ListItem>Vocational college</asp:ListItem> <asp:ListItem>Bachelors degree</asp:ListItem> <asp:ListItem>Masters degree</asp:ListItem> <asp:ListItem>PhD or other doctorate</asp:ListItem> </asp:RadioButtonList> <br/> <asp:LabelID="Label1"runat="server"Text="Label"></asp:Label> </div> </form>

  10. The Code protectedvoid RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { Label1.Text = "Your level of education is " + RadioButtonList1.Text; }

  11. The ListBox Assuming that you created a ListBoxlstEmployees: Protected voidbtnAdd_Click(object sender, EventArgs e) { if (lstEmployees.SelectedIndex > -1) { string_value = lstEmployees.SelectedItem.Value;//Gets the value of items in list. string _text = lstEmployees.SelectedItem.Text;//Gets the Text of items in the list. ListItem item = newListItem (); //create a list item item.Text = _text; //Assign the values to list item item.Value = _value; lstSelectedEmployees.Items.Add(item); //Add the list item to the selected list of employees lstEmployees.Items.Remove(item); //Remove the details from employee list }