I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component public class AllViewComponent : ViewComponent { private readonly UserManager<ApplicationUser> _userManager; public AllViewComponent(UserManager<ApplicationUser> userManager) { _userManager = userManager; } public async Task<IViewComponentResult> InvokeAsync() { List<StudentViewModel> allUsers = new List<StudentViewModel>(); var items = await _userManager.Users.ToListAsync(); foreach (var item in items) { allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email }); }
If you want to get Text from radio button then first to determine whether the radio button is checked or not , if it is checked then return true. Using the name property, you will get element of html control. ':Checked' property check the status of html control. Suppose your radio button return true (it means checked) then you will get the value of radio button control using the val( ) method.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Get Text Of Radio Button</title>
<script src="Scripts/jquery-1.10.2.js"></script>
<script>
$(function () {
$('#Button1').click(function () {
var rdtxt = $('input[name=rd]:Checked').val();
alert(rdtxt);
})
});
</script>
</head>
<body>
<form id="form1" runat="server">
<input id="Radio1" type="radio" value="Gender" name ="rd"/>Gender<br />
<input id="Button1" type="button" value="button" />
</form>
</body>
</html>
Now lets take an simple example
<%@ Page Language="c#" %><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Get Text Of Radio Button</title>
<script src="Scripts/jquery-1.10.2.js"></script>
<script>
$(function () {
$('#Button1').click(function () {
var rdtxt = $('input[name=rd]:Checked').val();
alert(rdtxt);
})
});
</script>
</head>
<body>
<form id="form1" runat="server">
<input id="Radio1" type="radio" value="Gender" name ="rd"/>Gender<br />
<input id="Button1" type="button" value="button" />
</form>
</body>
</html>
Comments
Post a Comment