In the following program there are three radio buttons and one submit button whenever we click on one radio button and click on submit it will display a simple msg i.e., your favourite image is teddy like that for this design first we open visual studio and select asp.net application in that we select a webform1 on that select WebForm1.aspx design and drag and drop the all required controls i.e.,three radio buttons,one label,one button.Write a logical code in WebForm1.aspx.cs file.
In the following program there are three radio buttons and one submit button whenever we click on one radio button and click on submit it will display a simple msg i.e., your favourite image is teddy like that for this design first we open visual studio and select asp.net application in that we select a webform1 on that select WebForm1.aspx design and drag and drop the all required controls i.e.,three radio buttons,one label,one button.Write a logical code in WebForm1.aspx.cs file.
TOP MOST Asp.Net programs
Select your favourite image
your favourite image is:Teddy
Solution:WebForm1.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace task_5
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (RadioMoon.Checked)
{
lblMsg.Text = "your favourite image is:" + RadioMoon.Text;
}
else if (RadioRoses.Checked)
{
lblMsg.Text = "your favourite image is:" + RadioRoses.Text;
}
else if (RadioTeddy.Checked)
{
lblMsg.Text = "your favourite image is:" + RadioTeddy.Text;
}}}}
WebForm1.aspx(design)
Select your favourite image[lblMsg]
2.WebForm1.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace task_6
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (RadioButtonList1.SelectedIndex == 0)
{
Image1.ImageUrl = "Moon.jpg";
}
else if (RadioButtonList1.SelectedIndex == 1)
{
Image1.ImageUrl = "Roses.jpeg";
}
else if (RadioButtonList1.SelectedIndex == 2)
{
Image1.ImageUrl = "Teddy.jpg";
}
}
}}
WebForm1.aspx(design)
0 comments:
Post a Comment