0% found this document useful (0 votes)
113 views29 pages

Write AWD Practical

dfdfv v

Uploaded by

np513325
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
113 views29 pages

Write AWD Practical

dfdfv v

Uploaded by

np513325
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 29
Ta Crest an application to print onscreen te ott of nding, subtracting, tpn and dividing two munbers tered by the werin CA Eater Fiat umber: Eater Second auaer: ‘Addition: Label Soberaton:Label_Muliplication: Label_ Divison: Label Gusing System; using System.Collections.Generic; using System.Ling; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; Sipublic partial class _1a : System.Web.UI.Page { public void Page_Load(object sender, EventArgs e) { 3 | protected void Button1_Click(object sender, EventArgs e) { int a = int.Parse(TextBox1. Text); int b = int.Parse(TextBox2. Text) ; Label1.Text = (a + b).ToString(); Label2.Text = (a - b).ToString(); Label3.Text = (a * b).ToString(); if (b != @) { Label4.text = (a / b).Tostring(); 3 else {| Label4.Text = "Cannot divide by zero"; 3 } 1b. Create an application to print Floyd’s triangle till n rows in C#. Enter the number of rows for Floyd's Triangle: Build | Floyd's Tringle Label [tb using System; using System.Collections.Generic; using System.Ling; using System.Web; using System.Web.UI; using System.Web .UT.WebControls; Fipublic partial class _ib : System.Web.UI.Page { protected void Page_Load(object sender, Eventargs e) t 3 Fprotected void Button1_Click(object sender, EventArgs e) { int n, number = 1; n = int.Parse(TextBoxl.Text); string result = ""; for (int i = 3 it) { for (int j = 1; j <= is j++) { result += number +" "5 number++; 3 result += "
"; + Label1.Text = result; 1c. Create an application to demonstrate following operations i. Generate Fibonacci series. Fibonacci sequence Enter n: Display | Label Iclaspx.cs [ %¢Practia1 +|5%Buttont_cl Gusing System; using System. using System. using System. using System. using System -Collections.Generic; -Ling; -Web; -Web.UL; -Web.UI.WebControls; Sipublic partial class Practid1 : System.Web UI.Page { protected void Page_Load(object sender, Eventérgs e) { } 5 protected void Button1_Click(object sender, EventArgs e) { int a, b, c, n, i; n = int.Parse(TextBox1.Text); a =0; b=1; Labell.Text = a + "
" + b + "
"; for (i = 33 i <=n5 itt) { c=a+b; Labell.Text += ¢ + "
"; a=; b=c; } 3 1c. Create an application to demonstrate following operations ii. Test for prime numbers. Test for prime numbers. Enter u: Check Label ‘4g Practid2 [Busing Syste using System.Collections. Generic; using System.Ling; using System.Web; using System.Web.UI; using System.Web .UI.WebControls; { Fipublic partial class Practid2 : System.Web.UT.Page protected void Page_Load(object sender, Eventargs e) { 3 protected void Button1_Click(object sender, EventArgs e) { int i, n, count - 0; n = int.Parse(TextBox1.Text) ; for (i = 1; i <=n; ist) { if (n%i == 0) count++5 } 3 if (count == 2 || n { 1) Label1.Text =n +" is prime"; 3 else { Label1.Text =n + " is not prime"; } [boay | 2a. Create a simple application to demonstrate the concepts boxing and unboxing Boxing and Unboxing Example Demonstrate Boxing Jemonstrate Unboxing [IbIMessage] 4520 using System; using System. Collections Generic using System.Ling; using System.Web; using System.Web.UI; using System.Web.UI.NebControls; public partial class _2a : System.Web-UT.Page t protected void Page_Load(object sender, EventArgs e) t i) eB protected void btnBoxing_Click(object sender, EventArgs e) { int m= 10; object om = m; m= 20; IbMessage.Text = "After foxing:
" + “value of m (int): "+ m+ “ebr/>" + “Value of om (object): " + om.ToString(); Loo 5 protected void btnUnboxing_Click(object sender, EventArgs e) { object om = 188; int n = (int)om; IbIMessage.Text = "After Unboxing:
" + “value of om (abject): "+ om.ToString() + "
" + “value of n (int): " + n.ToString(); y ‘7b. Create a simple application to perform addition and subtraction using delegate. Delegate “cae Label Label ielop Glusing System using System.Collections Generic; using System. Ling; using System using System.Web.UI; using System.Web.UI.WebControls; delegate int delop(int a, int b); public class op { ©} public int add(int a, int b) { return (a +b); 3 public int subi(int a, int b) { return (a - b); 3 3 Spublic partial class Pract2c1 : System.Web.UI.Page { 8 protected void Page_Load(object sender, EventArgs e) { 3 5 protected void Buttonl_Click(object sender, EventArgs e) { op o1 = new op(); delop d1 = new delop(o1.add); Label1.Text = d1(10, 20).ToString(); d1 = new delop(o1.sub1); Label2.Text = d1(10, 20).ToString(); 3 2c. Create a simple application to demonstrate use of the concepts of interfaces. Thterfaces Click Label Label 4 Pract2b4 using System using System.Collections.Generic; using System. using System. using System.Web.UI; using System.Web.UI.WebControls; Eipublic partial class Pract2b4 : System.Web.UI.Page { E protected void Page_Load(object sender, EventArgs e) { 3 El protected void Buttont_Click(object sender, EventArgs e) { Circle obj1 = new Circle(); Rect obj2 = new Rect(); Label1.Text = obj1.show(5, 5).ToString(); Label2.Text = obj2.show(2, 3).ToString(); } } Glinterface Area { double show(double a, double b); + class Circle : Area C = public double show(double a, double b) { return (3.14 * a * a); 3 + class Rect : Area t =| public double show(double a, double b) { return (a * b); 3 (rarer cos [bens Select Ci ett com oH Disp Label Label Label Label abel [abel Practical 3. =i 5 Ws using System, using System.Collections.Generic; using System.Ling; using System.Web; using System.Web.UI; using System.Meb.UT.WebControls; public partial class Practical_3 e : System.Web.UI.Page t El protected void Page _Load(object sender, EventArgs e) { } protected void CheckBoxl_CheckedChanged(object sender, EventArgs e) { 1 protected void TextBox1_TextChanged(object sender, EventArgs e) { } protected void Buttonl_Click(object sender, EventArgs e) { Label. Text = TextBox1.Te Label2.Text = TextBox2.Text; Label3.Text = RadioButtonList1.SelectedValue; Label4.Text = CheckBoxList1.SelectedValue; LabelS.Text = ListBox1.SelectedItem.Value; Label6. Text = DropDownlist1.SelectedItem.Value; 43b. Create a simple application to demonstrate your vacation using calendar control. < September 2024 Sun Mon Tue Wed Thu 25 26 27 28 29 19203 4 55 8 9 10 IL 12 15 16 17 18 19 22 23 24 25 26 29°30 1 2 3 ‘Your selected date: Select a date Today's Date: Label Summer Vacation Start at: Label Days remaining for summer vacation: Label [Resa] Fri 30 6 13 20 21 4 > Sat 31 7 14 21 28 5 Practical 3b Busing System; using System.Collections.Generic using System-Ling; using System.Web; using System.Web.UT5 using System.Web.UI. WebControl; Eipublic partial class Practical_3_b : System.Web.UE.Page { protected void Page Load(object sender, EventArgs e) t t protected void Calendari_SelectionChanged(object sender, EventArgs e) t } protected void Button Click(object sender, EventArgs e) Ht Calendari.Caption = "Vacation Calendar”: Calendar. FirstDayOfWeek = FirstDayOFieck. Sunday; Calendar. NextPrevFormat = tiext? rev onset -ShortHonth; Calendar. TitleFormat = TitleFormat.Months Label text Label2. Text Calendar1.SelectedDate. ToString("dd-M-yyvy"); Calendar1. TedaysDateToshortDateString(); Label3 Text = "11-04-2025" Timespan vacationDuration = new DateTine(2025, 4, 11) - DateTine.Wows Label4.Text = vacationduration.Days.Tostring() +" days until vacation starts"; } protected void Calendar DayRender(object sender, DayRenderFventirgs e) d if (eDay.Date.Day == 11 && e.Day.Date.Month == 4 && e.Day.Date.Vear == 2025) { e.Cell.BackColor = System.Drawing. Color.LightGreen; Label Il = new Label(); bl. Text = “Vacation Starts e.Cell.Controls.Add(1b1); } [body | 3c. Demonstrate the use of Treeview operations on the web form. = Home 2 Fashion Clothes. Winterwear Shoes 8 Product TVs DTHs DVDs LCDs SiteMapDataSource - SiteMapDataSourcet Sayyad Bilal Ahmad 51 ‘Name: can't empty Age: can't empty1$+ Email id: can't empty enter valid email Password: can't empty Confirm Password: can't emptypassword are different ‘Submit + Exror message 1. + Exror message 2. 4b. Create Web Form to demonstrate use of Adrotator Control. a dc. Create Web Form to demonstrate use User Controls. Welcome to ASP.NET wou 5a. Create Web Form to demonstrate use of Website Navigation controls Home> = Home & Fashion Clothes Winterwear Shoes = Product TVs DTHs DVDs LCDs SiteMapDataSource - SiteMapDataSourcet Practical-5 C a) Hidden Field Client-site state management HiddenField - Hiddenfield1 Label Label Submit) AgPract 5a Elusing System; using System.Collections .Generic; using System. Ling; using System.Web; using System.Web.UI; Lusing System.Web.UI.WebControls; [public partial class Pract_5_(_a : System.Web-UI.Page t El protected void Page_Load(object sender, EventArgs e) { 3 El protected void Buttont_Click(object sender, EventArgs e) { if (HiddenFieldi.Vvalue != null) { int val = Convert .ToInt32(HiddenField1.Value) + 1; HiddenField1.Value = val.ToString(); Labell.Text = val.ToString(); } int val1 = Label2.Text = (veld + 1).ToString(); L, 3 + Practical-5 C b) Query String First Named ‘Last Namel ‘Submit 4g Practical 5.Cb1 [i Page Load(object Busing Systems using Systen.Collections.Generics using System. Linas using Systen.Webs using System.Web. UT using System.Web .UI-WebControlss public partial class Practical 5 ¢ b 1 + System.Wleb.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Buttoni_Click(object sender, EventArgs e) i Response. Redirect ("5cb2.aspx?lin="+ TextBox1. Texte” @liml="+ TextBox2.Text) 5 } =osing Syston Using systen-Collections.Generic; Using Systen Linas Using system ued; Using Systemes Urs Using System Meb UL WebControls; public partial class Practical s ¢ 2) protected void Page Lood(object senders EventArgs) 12 Systom.eb.Ur Page 4 2 Cremest. gesting") Ie tt Labeld. Text = Labeli-Text +” * + Request. Querystring"n"]+” “HRequest.QueryStrine[ "tel" Is ? ise Labeld-Toxt = "Sone problem occured"; > y ob A practs using System; using System-Collections Generics using System-Lings using System-Neb; using System-Neb-UT; Lusing System.Web.UI.WebControls; © 5 System.Web-UI.Paze [public partial class pract5_< t protected void Page_load(object sender, EventArgs e) £ if (Request.Cookies["Bc"] I= null) { DropDownList1.SelectedValue = Request .Cookies{ "BGC" ].Value; bodytag.Style[ "background-color"] = DropDownList .SelectedValues DropDownList1.Visible = false; 3 + protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { HetpCookie obj = new HttpCookie("BGC") ; obj.Value = DropownList1.SelectedValue; obj.Expires = DateTine.Now.AddMinutes(3) ; Response. SetCookie(ob3); ractical 5_c_d View State bel Get Data % practS_cd [sing System; using System.Collections Generic; using System.Ling; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; Frublic partial class pract5_c_d : System.Web.UI.Page a protected void Page_Load(object sender, EventArgs e) * (JIsPostBack) string str = “Bilal Ahmad”; if (ViewState["nam"] == null) { ViewState["nam"] = str; } a Protected void Buttonl_Click(object sender, EventArgs e) if Label1.Text = ViewState[ “nam"].ToString(); Practical 5_c_e Click Label practSce Slusing System; using System.Collections.Generic; using System. Ling; using System.Web; using System.Web.UI; using System.Neb.UT.WebControls; Spublic partial class pract5_c_e : System.Web.UI. Page { { | a { } HW protected void Page_Load(object sender, EventArgs e) protected void Buttonl_Click(object sender, EventArgs e) int ent = 0; if (Session["Visit"] != null) { ent = Convert.ToInt32(Session[ "Visit" ].ToString()); 3 cnt = cnt + 15 Session[ "Visit Label1.Text = cnt; Total Visit + ent.ToString(); 4G practic {_ 5 using System; using System.Collections Generic; using System. Ling; using System.Web; using System.Web.UI; using System.Web.UT.WebControls; public partial class practSc_f_ : System.Web.UT.Page { [protected void Page_Load(object sender, EventArgs e) { + protected void Button1 Click(object sender, EventArgs e) { int count = 05 if (Application[“Visit"] != null) { count = Convert .ToInt32(Application[ "Visit" ].ToString()); } count = count + 1; Applicetion["Visit"] = count; Label1.Text = “Total Visit -" + count.ToString(); 6a. Create a web application for inserting and deleting records from a database. | Enter author name: Enter phone number: Insert Delete Reset Label fanaa [oar Sesing Sten; ‘sing System Collections. Generics Shing Syaten Ling, ‘sing Systeme; eins Syaten Mes UT; {Sing Syston Meb UT Mebcontrols; ‘sing Syaten Dates ‘sing System Dato Salient; Sepuoc partial class Practical 7. + Syston Meb.UL Page « static string str = @'0sta sourcesep\saleapress;Initial Catalog-bial; Integrated Securty-TruejPooling-False"; Sqiconpection ean = new Selconneceson(ste)y Salcomand end protected void Page_Loadobject sender, Guetiegs «) t protected void Guttont Cick(object sender, Gertirgs e) t con.Open0 fad = ren Sglcomand("insert inte beok(authorphne) values(""+ TextBox-Text 4°","* TextBoxText +°)"ycon); end bxecutlonuery()3 bela Text = “bata aided successfully on-close0 5 protected void Gutton) Cick(object sender, Gertirge e) brotected void Sutton? Cick(object sender, Sertirgs e) 4 conden nd = row Salonmand("delete from bok were authar='" TextBox Texts” "*,con nd bxecutlenuery()3 UGhela-Text = “Date deleted successfully" fon-close0 5 ‘6b. Create a web application to display Using Disconnected Data Access and Databinding using GridView. Glick to See the data of employee table ‘Column0 Columat Column2| abe = abe abe abe = abe abe abe abe abe abe = abe abe abe abe abe fe [sine stews ‘sing systen.Collections.seneric; sing Systen-Lings ‘sing system Keb; ‘sing Syston UT; sing System eb UT MebControls; sing Systen Ontos [ising Syston. Date,SqlC1ents public partial class 0b + System.eb.UI.Pose 4 statle string str = @"bata Source-Wo\salexpress;initial Catelog-bil Saltonnection eon = new SalCannection( st) Sqldatatiapter des protected void Poze LeadCobject sender, Eventaras @) Integrated Secunity-truesPooLing-False"s 4 ) 5 protected woid Buttont_Click(obiect sender, Evertras @) « con.open0: a" new ldatondopter("select * from employee", con): Dataset de = new OatasctOs ae. Grisvicwd.OatoSource = €s.Tobles(01; GrieViee.DatesineC); ) mmaseb {recreate web aplication demonstte Form Secwiy and Windows Sect wit proper Auhewicaon and Autoiatin properties “ain be — el (a —oSSssssooswsaaw>a—=—s using System; ‘using System. Collect ons Generic; using Systen-Lings Using System Webs fusing System: Meb: U5 ‘ising System. Msb.UL-MebControlss | [using System.Web. Security; fblic partial class 7 + System.Web.UT.Page { [protected void Page_Load(object sender, eventires e) t + protected bool authenticate(String uname, String pass) return trues 1 1 3 (uname == "archona")¢ if (pass == “dhawade") return trues + | if (uname == "admin" ){ if (pass == "123") return trues } return false; } protected void Buttonl_Click(object sender, FventAres e) « Lf (authenticate(TextBoxl.Text, TextBox2.Text)) « FormsAuthentication RedirectFromLoginPage(TextBox1.Text, Check#oxl.Checked); Session{ "Usernane"] = TextBox1.Text; Response.Redirect(*welcome. aspx"); t else « Response.Write("Invalid user name or password”); See Syston: Collections. Generic Using Systen: Linas Using Systen Keb: Seing Systen Ue UT; sing Systen Web. UT MebControtss Using Syston. Osta; Using Syston Dato, SalClient; € static string str Sxitonrection gon Saitonmans ends 5 protected void Page Load(object sender, Eventrgs e) e°tate source-veo\salespress;tnitial Cetalog-bilalstotegrated Securlty=Teue;PooLing=False"; fhe SelConnection(ste)s t ) © protected void auttonl Click(object sender, Eventhegs @) © protected void Suttons Click(otject sender, Eventiegs 6) t © protected void dutton2 Click(otject sender, Eventiegs «) t «on. 0pen()s (end = new SqlComand(“delete from book where authors" TextBox Texte""*jcon)5 na-Eeeectetanducry(); . con. closets : ? ? Lwouy J 8b. Create a web application for user defined exception handling. User defined exception handling Click Label Label SSS Susing System; using System. Collections.Generic; using System. Ling; using System.Web; using System.Web.UI; lusing System-Neb.UL-WebControls; public class CustonException : Exception t public CustomException(string message) : base(message) { + + public partial class sb + Systen.Web.UL.Poge { protected void Pogetoad(object sender, EventArgs e) { Loo protected void Buttont Click(object sender, Cventrgs e) { ! try int a, by I ‘throw new CustowException("Custom Error: Division by zero is not allowed!"); + c= 0/ bs Label1.Text = c.ToString(); y I catch (Custontxception ex){ Label Text = ex.Messezes y I catch (System.Exception ex){ Label Text = "System Exception: " + ex.Messages 7 1 Finally{ Label2.Text = “Thonk You!" , + 90. Create a web application to demonstrate data binding using Details View and Fonn View Control. DetailsView _usemame Databound | password Databound. 12 | SqlDataSource -SqlDataSourcet ‘FormView jusername: Databound | password: Databound 12 }10a. Create a web application to demonstrate JS Bootstrap Button. Bootstrap Button Example This example shows how to use a Bootstrap-styled button with JavaScript functionality. lick Me {IbiMessage} 10b. Create a web application to demonstrate use of various Ajax controls. Label Button Loading.....Please wait... %$_10b Glusing System; using System. Collections. Generic; using System.Ling; using System.Web; using System.Web.UI; using System.Web.UT.WebControls; Elpublic partial class _10b : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) { 3 Label1.Text = DateTime .Now.ToLongTimeString() ; { | protected void Button1_Click(object sender, EventArgs e) { system. Threading. Thread .Sleep(3000); 3 +

You might also like