(in vs 2015/asp.net/web forms template)there is several web pages like Register page and login page.all the elements on this pages is created with bootstrap , but I wondered there isn't any bootstrap link command in html source of this pages :
<%# Page Title="Log in" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="Login.aspx.vb" Inherits="Account_Login" Async="true" %>
<%: Title %>.
<div class="row">
<div class="col-md-8">
<section id="loginForm">
<div class="form-horizontal">
<h4>Use a local account to log in.</h4>
<hr />
<asp:PlaceHolder runat="server" ID="ErrorMessage" Visible="false">
<p class="text-danger">
<asp:Literal runat="server" ID="FailureText" />
</p>
</asp:PlaceHolder>
<div class="form-group">
<asp:Label runat="server" AssociatedControlID="UserName" CssClass="col-md-2 control-label">User name</asp:Label>
<div class="col-md-10">
<asp:TextBox runat="server" ID="UserName" CssClass="form-control" />
<asp:RequiredFieldValidator runat="server" ControlToValidate="UserName"
CssClass="text-danger" ErrorMessage="The user name field is required." />
</div>
</div>
<div class="form-group">
<asp:Label runat="server" AssociatedControlID="Password" CssClass="col-md-2 control-label">Password</asp:Label>
<div class="col-md-10">
<asp:TextBox runat="server" ID="Password" TextMode="Password" CssClass="form-control" />
<asp:RequiredFieldValidator runat="server" ControlToValidate="Password" CssClass="text-danger" ErrorMessage="The password field is required." />
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<div class="checkbox">
<asp:CheckBox runat="server" ID="RememberMe" />
<asp:Label runat="server" AssociatedControlID="RememberMe">Remember me?</asp:Label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<asp:Button runat="server" OnClick="LogIn" Text="Log in" CssClass="btn btn-default" />
</div>
</div>
</div>
<p>
<asp:HyperLink runat="server" ID="RegisterHyperLink" ViewStateMode="Disabled">Register</asp:HyperLink>
if you don't have a local account.
</p>
</section>
</div>
<div class="col-md-4">
<section id="socialLoginForm">
<uc:openauthproviders runat="server" id="OpenAuthLogin" />
</section>
</div>
</div>
where can I find the bootstrap link command?
HI Pooya as you can see this page is child page and all the links are define in master like bootstrap and js file
Child page - login.aspx
Master Page - site.master
so you can find all the link in site.master page
I am using Bootstrap 3 with ASP.NET webforms and I am completely new to Bootstrap. The webform I am working on uses ASP.net validation controls. My web form has a standard layout with two columns and I am using "form-group" class to group my labels and input fields.
Now the problem is that as I am placing the label, input field as well as its validator in the Bootstrap "form-group" class, the message in the text property of the validator is being displayed in the next line after validation. I want that to be displayed right next to the input field. Is there any alternative way I can do this?
<div class="form-group">
<asp:Label runat="server" AssociatedControlID="txtBox">Address <span class="required">*</span></asp:Label>
<asp:TextBox id="txtBox" runat="server" CssClass="form-control"/>
<asp:RequiredFieldValidator ID="rfvLine1" ValidationGroup="<%# ValidationGroup %>" ControlToValidate="txtBox" runat="server" Display="Dynamic" ErrorMessage="Line 1 is required." Text="*"/>
</div>
Easiest way is to create validation in separate column.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style type="text/css">
.required {
color: #e31937;
font-family: Verdana;
margin: 0 5px;
}
.field-validation-error {
color: #e31937;
font-weight: bold;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<br />
<div class="container form-horizontal">
<div class="form-group">
<asp:Label runat="server"
AssociatedControlID="txtBox"
CssClass="col-xs-12 col-sm-4 control-label">
Address
<span class="required">*</span>
</asp:Label>
<div class="col-xs-12 col-sm-4 ">
<asp:TextBox ID="txtBox" runat="server"
CssClass="form-control" />
</div>
<div class="col-xs-12 col-sm-4 form-control-static">
<asp:RequiredFieldValidator ID="rfvLine1"
ControlToValidate="txtBox" runat="server"
Display="Dynamic"
CssClass="field-validation-error"
Text="Line 1 is required." />
</div>
</div>
<div class="form-group">
<div class="col-xs-12 col-sm-offset-4 col-sm-4 ">
<asp:Button runat="server" ID="SubmitButton"
Text="Submit" CssClass="btn btn-primary" />
</div>
</div>
</div>
</form>
</body>
</html>
Do the following: Updated
<div class="container">
<h4 class="form-signin-heading">Info</h4>
<div class="form-group">
<div class="col-xs-7 col-sm-7">
<asp:TextBox runat="server" placeholder="Garage Name" CssClass="form-control username" ID="txtAddress"></asp:TextBox>
</div>
<div class="col-xs-7 col-sm-5">
<span class="help-inline pull-left">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtAddress"
ErrorMessage="Address is a required field."
ForeColor="Red" Display="Dynamic">
</asp:RequiredFieldValidator>
</span>
</div>
</div>
<br />
<br />
<div class="form-group">
<div class="col-xs-7 col-sm-7">
<asp:Button ID="Button1" runat="server" Text="Add" CssClass="btn btn-lg btn-primary btn-block" />
</div>
</div>
</div>
I hope, this is what you expected:
By the way, you didn't put the end tag in the RequiredFieldValidator.
#jQuery for check "require" validation for only submit button#
<script type="text/javascript">
(function () {'use strict';
window.addEventListener('load', function () {
var form = document.getElementById('needs-validation');
form.addEventListener('submit', function (event) {
if (form.checkValidity() === false)
{
event.preventDefault();
event.stopPropagation();
}
form.classList.add('was-validated');
}, false);
}, false);
})();
##Submit button HTML##
<asp:Button ID="Button1" runat="server" Text="Submit" class="btn btn-primary" OnClick="Button1_Click" />
##Non Submit button##
<asp:Button ID="btnSearch" runat="server" class="form-control btn-primary " Width="25%" Text="Find" UseSubmitBehavior="false" OnClick="btnSearch_Click" />
I am not sure how to formulate the title of this issue. My problem is that I have a .ascx control which has control. When I make a page where I have buttons in the content, pressing the button causes Submit button to be fired.... I have absolutely no idea why this happens. Please give me any suggestions or idea how to fix this.
My Control code is :
<%# Control Language="VB" AutoEventWireup="false" CodeFile="TopRightMenuAnonn.ascx.vb" Inherits="Ctrls_TopRightMenuAnonn" %>
<ul class="nav pull-right" id="top-right_menu">
<li style="padding: 5px" class="dropdown">
<a class="dropdown-toggle" href="#" data-toggle="dropdown" style="padding:10px 15px;color: #73767D">Login<strong class="caret"></strong></a>
<div id="loginForm" class="dropdown-menu pull-right" style="padding: 15px;">
<asp:Login runat="server" ID="login1" DestinationPageUrl="~/Home.aspx">
<LayoutTemplate>
<asp:TextBox runat="server" ID="Username" style="margin-bottom:15px;" PlaceHolder="Username" Height="30px"></asp:TextBox>
<asp:TextBox runat="server" ID="Password" style="margin-bottom: 15px;" PlaceHolder="Password" Height="30px" TextMode="Password" />
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="Username" style="color: red" Text="Please enter an username."></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" style="color: red" Text="Please enter a password."></asp:RequiredFieldValidator>
<asp:Label ID="lblError" runat="server" Visible="false" Text=""></asp:Label>
<asp:Button ID="Login" runat="server" CommandName="Login" CssClass="btn btn-primary" style="clear: left; width: 100%; height: 32px; font-size: 13px;" Text="Sign In"></asp:Button>
Forgot password?<br />
<!--Fancybox for pass-->
<div style="display:none">
<div id="getpass" style="width: 100%;height:100%">
<span>Please enter your username to retrieve your password.</span>
<br />
<asp:TextBox runat="server" ID="txtForgotPass" PlaceHolder="Username" Height="30px" Width="100%" style="margin-top: 20px;margin-bottom:20px;"></asp:TextBox>
<asp:Button runat="server" ID="btnForgotPass" CssClass="btn btn-primary" style="clear:left;float: right;padding:10px" Text="Send My Password" />
</div>
</div>
<!--End of fancybox for pass-->
Forgot username?
<!-- Fancybox for user -->
<div style="display:none">
<div id="getuser" style="width: 100%;height: 100%">
<span>Please enter your e-mail to retrieve your username.</span>
<br />
<asp:TextBox runat="server" ID="txtForgotUser" PlaceHolder="example#materialconnexion.com" Height="30px" Width="100%" style="margin-top: 20px; margin-bottom: 20px;"></asp:TextBox>
<asp:Button runat="server" ID="btnForgotUser" CssClass="btn btn-primary" style="clear:left;float: right;padding: 10px" Text="Send My Username" />
</div>
</div>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="login1" />
<!-- End of fancybox for user-->
</LayoutTemplate>
</asp:Login>
</div>
</li>
<li style="padding: 15px;border-left: 1px solid #999"><a style="padding: 0px !important;color: #73767D" href="../regtest.aspx">Register</a></li>
<li style="padding: 15px;border-left: 1px solid #999"><a style="padding: 0px !important;color: #73767D" href="../Pricing.aspx">Buy Credits</a></li>
</ul>
My control back-end code is(this is where shit happens and I cant figure out a way to make it work properly) :
Option Strict On
Partial Class Ctrls_TopRightMenuAnonn
Inherits System.Web.UI.UserControl
Protected Sub login1_LoggingIn(sender As Object, e As LoginCancelEventArgs) Handles login1.LoggingIn
Dim m As New MemberData(New MatconnDB(), login1.UserName)
If m.IsNew() Then
e.Cancel = True 'not in database
Return
End If
If m.ExpirationDate < Now() Then
e.Cancel = True
Return
End If
If m.Active = False Then
Return
End If
If m.unameEmail = False Then
Return
End If
If (MemberData.GetPassword(login1.UserName.ToString()) = MemberData.Encrypt(login1.Password.ToString())) Then
Session("User") = login1.UserName.ToString()
Response.Redirect("~/Home.aspx")
ElseIf MemberData.GetPassword(login1.UserName.ToString()) = login1.Password.ToString() Then
Session("User") = login1.UserName.ToString()
Response.Redirect("~/Home.aspx")
' Else
'I should put proper error messages here !!!!!!
End If
End Sub
End Class
My Master page file is :
<%# Master Language="VB" CodeFile="TopMenu.master.vb" Inherits="MasterPageLogged" AutoEventWireup="false" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>ssds</title>
</head>
<body>
<form id="form1" runat="server">
<div id="wrap">
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container" id="cont_left-menu">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#left-menu">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="HomePage.aspx">
<img style="margin-top: -5px;" src="../images/mc-logo.jpg" />
</a>
</div>
<div class="collapse navbar-collapse" id="left-menu">
<ul class="nav navbar-nav">
<li>
Services
</li>
<li>
Tool
</li>
<li>
Work
</li>
<li>
Matter
</li>
<li>
About
</li>
<li>
Contact
</li>
</ul>
<asp:ContentPlaceHolder runat="server" ID="ContentTopMenuRight">
</asp:ContentPlaceHolder>
</div>
</div>
</nav>
<asp:ContentPlaceHolder runat="server" ID="ContentPlaceHolder1">
</asp:ContentPlaceHolder>
</div>
</form>
<link type="text/css" rel="stylesheet" href="../css/bootstrap.css"/>
<link type="text/css" rel="stylesheet" href="../css/bootstrap-theme.css"/>
<link type="text/css" rel="stylesheet" href="../css/Styles.css" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../js/jquery.fancybox.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="../css/jquery.fancybox.css" type="text/css" media="screen" />
</body>
</html>
And my Simple test page is :
<%# Page Language="VB" AutoEventWireup="false" MasterPageFile="~/Masters/TopMenu.master" CodeFile="regtest.aspx.vb" Inherits="regtest" %>
<%# Register Src="~/Ctrls/TopRightMenuAnonn.ascx" TagName="TopRightMenuLogged" TagPrefix="tma" %>
<%# MasterType VirtualPath="~/Masters/TopMenu.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentTopMenuRight" runat="server">
<tma:TopRightMenuLogged ID="TopRightMenuLogged1" runat="server" />
</asp:Content>
<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
<div class="container">
<div class="col-md-6">
<asp:TextBox runat="server" ID="txtName" PlaceHolder="Name" class="txtedit"></asp:TextBox>
<asp:TextBox runat="server" ID="txtSurname" PlaceHolder="Surname" class="txtedit"></asp:TextBox>
<asp:TextBox runat="server" ID="txtMail" PlaceHolder="Email" class="txtedit"></asp:TextBox>
<asp:TextBox runat="server" ID="txtCompany" PlaceHolder="Company" class="txtedit"></asp:TextBox>
<asp:TextBox runat="server" ID="txtPass" PlaceHolder="Password" class="txtedit"></asp:TextBox>
<asp:TextBox runat="server" ID="txtPassV" PlaceHolder="Confirm Password" class="txtedit" AutoPostBack="True"></asp:TextBox>
<br />
<br />
<asp:CheckBox runat="server" ID="chkbox" Text=" Term and Conditions" style="margin-top: 10px" />
<br />
<br />
<br />
<br />
<asp:Button runat="server" ID="btnReg" Text="blqblq" />
<asp:Label runat="server" ID="lblText" Text=""></asp:Label>
<asp:Label runat="server" ID="lblCaption" Text=""></asp:Label>
</div>
</div>
</asp:Content>
Please advise..
Thanks in advance !
The MSDN docs page for the Button class states in a few places:
By default, all button controls submit the page when clicked.
It is unclear from your question which <asp:Button> control is causing the unwanted PostBack:
the one in your sample page (btnReg), or
one of the ones in your UserControl (Login, btnForgotPass, btnForgotUser)
However, if you don't want them to submit the page / cause a PostBack, then you need to
prevent that using client-side validation / etc, or
use a different control than <asp:Button> that does what you want it to.
i have inquiry form which gets open in modal popup extender. when i click on button to store data click event does not get fired
i don't know whats going wrong can any one help me to solve this problem
thanks in advance
here is my code
DefaultMaster.master
<%# Master Language="C#" AutoEventWireup="true" CodeFile="DefaultMasterPage.master.cs"
Inherits="DefaultMasterPage" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link type="text/css" rel="Stylesheet" href="../JyotiInstitute/Styles/StyleSheet.css" />
<link type="text/css" rel="Stylesheet" href="../JyotiInstitute/Styles/sliderman.css" />
<link type="text/css" rel="Stylesheet" href="../JyotiInstitute/Styles/style1.css" />
<link type="text/css" rel="Stylesheet" href="../JyotiInstitute/Styles/style2.css" />
<script type="text/javascript" src="Script/jquery-1.3.2.js"></script>
<script type="text/javascript" src="Script/scroll-startstop.events.jquery.js"></script>
<script type="text/javascript" src="Script/sliderman.1.3.7.js"></script>
<script type="text/javascript" src="Script/easytabs.js"></script>
<script type="text/javascript" src="Script/modernizr.custom.04022.js"></script>
<script type="text/javascript" src="Script/modernizr.custom.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
$('#toTop').fadeIn();
} else {
$('#toTop').fadeOut();
}
});
$('#toTop').click(function () {
$("html, body").animate({ scrollTop: 0 }, 600);
return false;
});
});
$(function () {
$('.fadein img:gt(0)').hide();
setInterval(function () {
$('.fadein :first-child').fadeOut()
.next('img').fadeIn()
.end().appendTo('.fadein');
},
4000);
});
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<div class="page-wrap">
<div id="absolute">
<div id="div1" class="div1">
<asp:ImageButton runat="server" ImageUrl="Images/sef111.png" Style="margin-top: 10px;
margin-left: 5px" ID="OpenPopUp1" CausesValidation="false" OnClick="OpenPopUp1_Click" />
<asp:Button ID="btnPopUp1" runat="server" Style="display: none" />
</div>
<div id="div2" class="div2">
<asp:ImageButton ID="OpenPopUp2" runat="server" ImageUrl="Images/scef1.png" Style="margin-top: 2px;"
CausesValidation="false" OnClick="OpenPopUp2_Click" />
<asp:Button ID="btnPopUp2" runat="server" Style="display: none" />
</div>
</div>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" BackgroundCssClass="modalBackground"
PopupControlID="Panel1" TargetControlID="btnPopUp1" CancelControlID="btnClose1">
</asp:ModalPopupExtender>
<asp:Panel runat="server" ID="Panel1" CssClass="modalPopup" align="center" Style="display: none">
<center>
<div class="outer_div">
<div class="inner_div">
<h1>
Student Enquiry Form</h1>
</div>
<div>
<br />
<asp:Literal runat="server" Text=" Your enquiry sent successfully..." ID="ltrMsg1"
Visible="false"></asp:Literal>
<br />
<asp:Label ID="Label2" runat="server" Text="Fileds marked with * are mandatory"></asp:Label>
<br />
<br />
<center>
<table>
<tr>
<td>
<asp:DropDownList ID="drpCourses" runat="server" CssClass="select">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:TextBox runat="server" ID="txtName" CssClass="textbox"></asp:TextBox><asp:TextBoxWatermarkExtender
ID="TextBoxWatermarkExtender2" runat="server" TargetControlID="txtName" WatermarkText="* Full Name ">
</asp:TextBoxWatermarkExtender>
</td>
</tr>
<tr>
<td>
<asp:TextBox runat="server" ID="txtEmail" CssClass="textbox"></asp:TextBox><asp:TextBoxWatermarkExtender
ID="TextBoxWatermarkExtender3" runat="server" TargetControlID="txtEmail" WatermarkText="* E-mail ID ">
</asp:TextBoxWatermarkExtender>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="TextBox1" runat="server" Text="+91" ReadOnly="true" CssClass="textbox"
Width="30px"></asp:TextBox>
<asp:TextBox runat="server" ID="txtMobile" CssClass="textbox" Width="172px"></asp:TextBox><asp:TextBoxWatermarkExtender
ID="TextBoxWatermarkExtender4" runat="server" TargetControlID="txtMobile" WatermarkText="* Mobile number ">
</asp:TextBoxWatermarkExtender>
</td>
</tr>
<tr>
<td>
<asp:TextBox runat="server" ID="txtCity" CssClass="textbox"></asp:TextBox><asp:TextBoxWatermarkExtender
ID="TextBoxWatermarkExtender6" runat="server" TargetControlID="txtCity" WatermarkText="City ">
</asp:TextBoxWatermarkExtender>
</td>
</tr>
<tr>
<td>
<asp:TextBox runat="server" ID="txtState" CssClass="textbox"></asp:TextBox><asp:TextBoxWatermarkExtender
ID="TextBoxWatermarkExtender5" runat="server" TargetControlID="txtState" WatermarkText="State ">
</asp:TextBoxWatermarkExtender>
</td>
</tr>
<tr>
<td>
<asp:TextBox runat="server" ID="txtComments" TextMode="MultiLine" CssClass="textboxMulti"></asp:TextBox><asp:TextBoxWatermarkExtender
ID="TextBoxWatermarkExtender7" runat="server" TargetControlID="txtComments" WatermarkText="Comments ">
</asp:TextBoxWatermarkExtender>
</td>
</tr>
<tr>
<td>
<br />
<center>
<asp:Button ID="btnSave" Text="Save" runat="server" CssClass="btnConrol"
onclick="btnSave_Click" />
</center>
</td>
</tr>
</table>
<%--<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Please select course"
SetFocusOnError="true" ControlToValidate="drpCourses" CssClass="ErrorMsg"></asp:RequiredFieldValidator><br />--%>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please enter full name"
SetFocusOnError="true" ControlToValidate="txtName" CssClass="ErrorMsg"></asp:RequiredFieldValidator><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Please enter Email-ID"
SetFocusOnError="true" ControlToValidate="txtEmail" CssClass="ErrorMsg"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="txtEmail"
ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*" runat="server"
CssClass="ErrorMsg" SetFocusOnError="true" ErrorMessage="Invalid Email" /><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="Please enter mobile number"
SetFocusOnError="true" ControlToValidate="txtMobile" CssClass="ErrorMsg"></asp:RequiredFieldValidator>
</center>
</div>
</div>
</center>
<asp:ImageButton ImageUrl="Images/close1.png" runat="server" ID="btnClose1" Style="float: right;
margin-top: -645px; margin-right: -20px;" />
</asp:Panel>
<asp:ModalPopupExtender ID="ModalPopupExtender_2" runat="server" BackgroundCssClass="modalBackground"
PopupControlID="Panel2" TargetControlID="btnPopUp2" CancelControlID="btnClose2">
</asp:ModalPopupExtender>
<asp:Panel runat="server" ID="Panel2" CssClass="modalPopup" align="center" Style="display: none">
<center>
<div class="outer_div">
<div class="inner_div">
<h1>
Institute Enquiry Form</h1>
</div>
<div>
<br />
<asp:Literal runat="server" Text=" Your enquiry sent successfully..." ID="ltrMsg2"
Visible="false"></asp:Literal>
<br />
<asp:Label ID="Label1" runat="server" Text="Fileds marked with * are mandatory"></asp:Label><br />
<br />
<table>
<tr>
<td>
<asp:TextBox runat="server" ID="txtFullName" CssClass="textbox"></asp:TextBox><asp:TextBoxWatermarkExtender
ID="TextBoxWatermarkExtender8" runat="server" TargetControlID="txtFullName" WatermarkText="* Full Name ">
</asp:TextBoxWatermarkExtender>
</td>
</tr>
<tr>
<td>
<asp:TextBox runat="server" ID="txtEmailId" CssClass="textbox"></asp:TextBox><asp:TextBoxWatermarkExtender
ID="TextBoxWatermarkExtender9" runat="server" TargetControlID="txtEmailId" WatermarkText="* E-mail ID ">
</asp:TextBoxWatermarkExtender>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="TextBox3" runat="server" Text="+91" ReadOnly="true" CssClass="textbox"
Width="30px"></asp:TextBox>
<asp:TextBox runat="server" ID="txtMobileNum" CssClass="textbox" Width="172PX"></asp:TextBox><asp:TextBoxWatermarkExtender
ID="TextBoxWatermarkExtender10" runat="server" TargetControlID="txtMobileNum"
WatermarkText="* Mobile number ">
</asp:TextBoxWatermarkExtender>
</td>
</tr>
<tr>
<td>
<asp:TextBox runat="server" ID="txtCityName" CssClass="textbox"></asp:TextBox><asp:TextBoxWatermarkExtender
ID="TextBoxWatermarkExtender11" runat="server" TargetControlID="txtCityName"
WatermarkText="City ">
</asp:TextBoxWatermarkExtender>
</td>
</tr>
<tr>
<td>
<asp:TextBox runat="server" ID="txtStateName" CssClass="textbox"></asp:TextBox><asp:TextBoxWatermarkExtender
ID="TextBoxWatermarkExtender12" runat="server" TargetControlID="txtStateName"
WatermarkText="State ">
</asp:TextBoxWatermarkExtender>
</td>
</tr>
<tr>
<td>
<asp:TextBox runat="server" ID="txtPin" CssClass="textbox"></asp:TextBox><asp:TextBoxWatermarkExtender
ID="TextBoxWatermarkExtender14" runat="server" TargetControlID="txtPin" WatermarkText="Pin Code ">
</asp:TextBoxWatermarkExtender>
</td>
</tr>
<tr>
<td>
<asp:TextBox runat="server" ID="txtComment" TextMode="MultiLine" CssClass="textboxMulti"></asp:TextBox><asp:TextBoxWatermarkExtender
ID="TextBoxWatermarkExtender13" runat="server" TargetControlID="txtComment" WatermarkText="Comments ">
</asp:TextBoxWatermarkExtender>
</td>
</tr>
<tr>
<td>
<br />
<center>
<asp:Button runat="server" ID="btnStore" Text="Save" CssClass="btnConrol"
onclick="btnStore_Click" />
</center>
</td>
</tr>
</table>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="Field cannot be left blank"
SetFocusOnError="true" ControlToValidate="txtFullName" CssClass="ErrorMsg"></asp:RequiredFieldValidator><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ErrorMessage="Field cannot be left blank"
SetFocusOnError="true" ControlToValidate="txtEmailId" CssClass="ErrorMsg"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="regEmail" ControlToValidate="txtEmailId" ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*"
runat="server" CssClass="ErrorMsg" SetFocusOnError="true" ErrorMessage="Invalid Email" /><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ErrorMessage="Field cannot be left blank"
SetFocusOnError="true" ControlToValidate="txtMobileNum" CssClass="ErrorMsg"></asp:RequiredFieldValidator>
</div>
</div>
</center>
<asp:ImageButton ImageUrl="Images/close1.png" runat="server" ID="btnClose2" Style="float: right;
margin-top: -630px; margin-right: -20px;" />
</asp:Panel>
<div id="head-wrap">
<div id="back-wrap">
</div>
<div id="menu">
<ul class="tabs">
<li>News </li>
<li>E-Prospectus</li>
<li>Help Center</li>
<li>Contact Us</li>
<li>Test</li>
</ul>
</div>
<div id="tab-container">
<div id="tabs">
<div id="logo_hm">
<div id="hm_outer">
<a href="Index.aspx">
<img alt="" src="Images/hm.png" style="margin-left: 4px; margin-top: 4px; border-radius: 5px" /></a>
</div>
</div>
<div id="tab_outer">
<div id="MainMenu">
<center>
<ul id="nav">
<li style="display: inline"><span>Home</span></li>
<li style="display: inline; top: 0px; left: 0px;"><a href="AboutUs.aspx"><span>About
Us</span></a> </li>
<li style="display: inline"><span>Academics</span>
<ul class="nav first">
<li>Overview</li>
<li>Ordinances & Regulations</li>
<li>Programmes </li>
</ul>
</li>
<li style="display: inline; width: 100px"><span>Study Centers</span>
<ul class="nav first">
<li>Join As Study Center</li>
</ul>
</li>
<li style="display: inline"><span>Downloads</span></li>
</ul>
</center>
</div>
<div id="search-box">
<div id="searchwrapper">
<form action="">
<asp:TextBox runat="server" ID="txtSearch" CssClass="searchbox"></asp:TextBox>
<asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server" TargetControlID="txtSearch"
WatermarkText="Courses, Study Centers">
</asp:TextBoxWatermarkExtender>
<%-- <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="Images/search1.png"
CssClass="searchbox_submit" PostBackUrl="~/Search.aspx" />--%>
<a href="Search.aspx">
<img alt="" src="Images/search1.png" class="searchbox_submit" /></a>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="middle-wrap">
<div id="left">
<div id="logo">
<img alt="" src="Images/Jyoti_logo .jpg" width="100%" height="100%" />
</div>
</div>
<div id="right">
<div style="float: left;">
<div id="slider">
<div id="Div3" class="fadein">
<img src="Images/c1.jpg" alt="" />
<img src="Images/c2.jpg" alt="" />
<img src="Images/c3.jpg" alt="" />
<img src="Images/c4.jpg" alt="" />
<img src="Images/c5.jpg" alt="" />
</div>
<div class="SliderName_3Description">
<span>Jyoti Institute of IT & Management</span>
<br />
<span style="text-transform: none; font-size: 14px">Jaunpur (UP)</span>
</div>
<%-- <div class="slider">
<center>
<div id="slider_container_3">
<div id="SliderName_3">
<img alt="" src="Images/c1.jpg" />
<img alt="" src="Images/c2.jpg" />
<img alt="" src="Images/c3.jpg" /><img alt="" src="Images/c5.jpg" />
<img alt="" src="Images/c4.jpg" />
</div>
<div class="SliderName_3Description">
<span>Jyoti Institute of IT & Management</span>
<br />
<span style="text-transform: none; font-size: 14px">Jaunpur (UP)</span>
</div>
</div>
</center>
<script type="text/javascript">
demo3Effect1 = { name: 'myEffect31', top: true, move: true, duration: 400 };
demo3Effect2 = { name: 'myEffect32', right: true, move: true, duration: 400 };
demo3Effect3 = { name: 'myEffect33', bottom: true, move: true, duration: 400 };
demo3Effect4 = { name: 'myEffect34', left: true, move: true, duration: 400 };
demo3Effect5 = { name: 'myEffect35', rows: 3, cols: 9, delay: 50, duration: 100, order: 'random', fade: true };
demo3Effect6 = { name: 'myEffect36', rows: 2, cols: 4, delay: 100, duration: 400, order: 'random', fade: true, chess: true };
effectsDemo3 = [demo3Effect1, demo3Effect2, demo3Effect3, demo3Effect4, demo3Effect5, demo3Effect6, 'blinds'];
var demoSlider_3 = Sliderman.slider({ container: 'SliderName_3', width: 790, height: 300, effects: effectsDemo3,
display: { autoplay: 3000 },
description: { background: '#000000', opacity: 0.5, height: 30, position: 'bottom' }
});
</script>--%>
</div>
</div>
</div>
</div>
</div>
<div id="Content-wrap">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="site-footer">
<center>
<span>© Copyrights, 2013 Jyoti Institute | Designed & Developed by Weblord Infotech</span>
</center>
</div>
</form>
</body>
</html>
DefaultMaster.master.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class DefaultMasterPage : System.Web.UI.MasterPage
{
Enquiry objEnquiry = new Enquiry();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void OpenPopUp1_Click(object sender, ImageClickEventArgs e)
{
ModalPopupExtender1.Show();
}
protected void OpenPopUp2_Click(object sender, ImageClickEventArgs e)
{
ModalPopupExtender_2.Show();
}
private void Clear()
{
drpCourses.SelectedIndex = 0;
txtName.Text = "";
txtFullName.Text = "";
txtEmail.Text = "";
txtEmailId.Text = "";
txtMobile.Text = "";
txtMobileNum.Text = "";
txtCity.Text = "";
txtCityName.Text = "";
txtState.Text = "";
txtStateName.Text = "";
txtPin.Text = "";
txtComment.Text = "";
txtComments.Text = "";
}
protected void btnStore_Click(object sender, EventArgs e)
{
//Studycenter enquiry form
//objEnquiry.EnterStudyCenterEnquiry(0, txtFullName.Text, txtEmailId.Text, txtMobileNum.Text, txtCityName.Text, txtStateName.Text, txtPin.Text, txtComment.Text);
ltrMsg2.Visible = true;
Clear();
}
protected void btnSave_Click(object sender, EventArgs e)
{
//Student enquiry form
//objEnquiry.EnterStudentEnquiry(0, drpCourses.SelectedItem.Text, txtName.Text, txtEmail.Text, txtMobile.Text, txtCity.Text, txtState.Text, txtComments.Text);
ltrMsg1.Visible = true;
Clear();
}
}
Is a request being submited to the server or is it not doing anything it all?
In the case of nothing happening my experience usually is a validationhandler that's invisible and blocking the call.
Try adding causesValidation="False" to your save button as a test to see if that is the issue
If it works without validation find the validator that's failing and fix it ! ;)
In my case I used UseSubmitBehavior="false". The reason behind this is explained here:
Microsoft Docs on UseSubmitBehavior
Gets or sets a value indicating whether the Button control uses the client browser's submit mechanism or the ASP.NET postback mechanism.
It appears that instead of trying to postback it was using the client browser submit so my code behind wasnt firing,
I have a asp.net page that has a master page and it contain RadioButtonList1 and I try to do the following:
<script type="text/javascript">
var radioButtonList = document.getElementById('<%=RadioButtonList1.ClientID%>');
if(radioButtonList[0].checked)
document.getElementById("_secondTR").style.display = "block";
else if (radioButtonList[1].checked )
document.getElementById("_secondTR").style.display = "none";
}
</script>
<table style="width: 100%">
<tr id="Tr1">
<td>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" BackColor="#FFCC99"
RepeatDirection="Horizontal" Width="117px" onclick="ShowHide()">
<asp:ListItem Value="1">Yes</asp:ListItem>
<asp:ListItem Value="0">No</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr id="_secondTR" runat="server" style="display: none">
<td>
<asp:RadioButton ID="Five" runat="server" GroupName="1" BackColor="#669999" />
<asp:RadioButton ID="Four" runat="server" GroupName="1" CausesValidation="True" BackColor="#669999" />
</td>
</tr>
</table>
I can't get RadioButtonList1 from JavaScript.
THE FOLLOWING IS THE actual javascript code seen by the browser
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
Untitled Page
</title>
</head>
<body>
<form name="aspnetForm" method="post" action="Default.aspx" id="aspnetForm">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTY3MTM1NjkwNw9kFgJmD2QWAgIDD2QWAgIBD2QWAgIBD2QWAgIBDxYCHgVzdHlsZQUNZGlzcGxheTpub25lO2QYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgQFLmN0bDAwJENvbnRlbnRQbGFjZUhvbGRlcjEkV2ViVXNlckNvbnRyb2wxJEZpdmUFLmN0bDAwJENvbnRlbnRQbGFjZUhvbGRlcjEkV2ViVXNlckNvbnRyb2wxJEZpdmUFLmN0bDAwJENvbnRlbnRQbGFjZUhvbGRlcjEkV2ViVXNlckNvbnRyb2wxJEZvdXIFLmN0bDAwJENvbnRlbnRQbGFjZUhvbGRlcjEkV2ViVXNlckNvbnRyb2wxJEZvdXLEUVfizbUknWTXdgpHXciIE+acfQ==" />
</div>
<div>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBgLV9tHzCQLJ7qOsBgLW7qOsBgLGgYnCCgKixI2BBALP88ewCU+8LBEmqBjXFfT7h0XYnYX89px3" />
</div>
<div>
asda sd sd as das
<script type="text/javascript">
function ShowHide()
{
var radioButtonList = document.getElementById('ctl00_ContentPlaceHolder1_WebUserControl1_RadioButtonList1');
if(radioButtonList[0].checked)
document.getElementById("_secondTR").style.display = "block";
else if (radioButtonList[1].checked )
document.getElementById("_secondTR").style.display = "none";
}
</script>
<table style="width: 100%">
<tr id="Tr1">
<td>
<table id="ctl00_ContentPlaceHolder1_WebUserControl1_RadioButtonList1" onclick="ShowHide()" border="0" style="background-color:#FFCC99;width:117px;">
<tr>
<td><input id="ctl00_ContentPlaceHolder1_WebUserControl1_RadioButtonList1_0" type="radio" name="ctl00$ContentPlaceHolder1$WebUserControl1$RadioButtonList1" value="1" /><label for="ctl00_ContentPlaceHolder1_WebUserControl1_RadioButtonList1_0">Yes</label></td><td><input id="ctl00_ContentPlaceHolder1_WebUserControl1_RadioButtonList1_1" type="radio" name="ctl00$ContentPlaceHolder1$WebUserControl1$RadioButtonList1" value="0" /><label for="ctl00_ContentPlaceHolder1_WebUserControl1_RadioButtonList1_1">No</label></td>
</tr>
</table>
</td>
</tr>
<tr id="ctl00_ContentPlaceHolder1_WebUserControl1__secondTR" style="display:none;">
<td>
<span style="background-color:#669999;"><input id="ctl00_ContentPlaceHolder1_WebUserControl1_Five" type="radio" name="ctl00$ContentPlaceHolder1$WebUserControl1$1" value="Five" /></span>
<span style="background-color:#669999;"><input id="ctl00_ContentPlaceHolder1_WebUserControl1_Four" type="radio" name="ctl00$ContentPlaceHolder1$WebUserControl1$1" value="Four" /></span>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
.net is generating a table for your list of buttons, radioButtonList referseto that table,
to get the buttons you need to add the following :
radioButtonList = radioButtonList.getElementsByTagName ('input');
That solves your immediate problem, but getElementById ('_secondTR') throws an error.
Changing the javascript to the following appears to do what you want.
function ShowHide () {
var radioButtonList = document.getElementById ('ctl00_ContentPlaceHolder1_WebUserControl1_RadioButtonList1');
radioButtonList = radioButtonList.getElementsByTagName ('input');
if (radioButtonList[0].checked)
document.getElementById ("ctl00_ContentPlaceHolder1_WebUserControl1__secondTR").style.display = "block";
else if (radioButtonList[1].checked )
document.getElementById ("ctl00_ContentPlaceHolder1_WebUserControl1__secondTR").style.display = "none";
}
I will have to defer to a .net expert to tell you how to cleanly generate this script.