我无法使用c#asp.net从日历中获取包含出生日期的输入字段值。我正在解释下面的代码。
index.aspx
:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="DoctorSignUp.aspx.cs" Inherits="Odiya_Doctor_Client.DoctorSignUp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div class="bannertopheader clearfix"></div>
<div class="col-md-6 bmargindiv1">
<label for="dateofbirth" accesskey="D"><span class="required">*</span> Date of Birth</label>
<asp:TextBox ID="txtDOB" name="dateofbirth" runat="server" ReadOnly="true" onchange="selectGender('dob');"></asp:TextBox>
</div>
<div class="col-md-12 bmargindiv1">
<asp:Button runat="server" Text="Submit" class="button" ID="doctorDetails" OnClick="doctorDetails_Click" />
</div>
</asp:Content>
Site.Master
:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="Odiya_Doctor_Client.SiteMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<title>Welcome to Odia Doctor</title>
<!--<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" /> -->
<meta charset="utf-8">
<meta name="author" content="odiadoctor" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
<link rel="shortcut icon" href="img/favicon.png" type="image/x-icon" />
<link rel="apple-touch-icon" href="img/apple_icons_57x57.png" />
<link rel="apple-touch-icon" sizes="72x72" href="img/apple_icons_72x72.png" />
<link rel="apple-touch-icon" sizes="114x114" href="img/apple_icons_114x114.png" />
<!--/ metas -->
<!-- styles -->
<link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/layerslider.css" />
<link rel="stylesheet" type="text/css" href="css/fullwidth/skin.css" />
<link rel="stylesheet" type="text/css" href="css/font-awesome.css" />
<link rel="stylesheet" type="text/css" href="css/owl.carousel.css" />
<link rel="stylesheet" type="text/css" href="css/jquery.fancybox.css" />
<link rel="stylesheet" type="text/css" href="css/styles.css"/>
<link rel="stylesheet" type="text/css" href="css/color-blue.css"/>
<link rel="stylesheet" type="text/css" href="css/intlTelInput.css" />
<link rel="stylesheet" type="text/css" media="all" href="css/daterangepicker-bs3.css" />
<!--/ styles -->
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div class="page">
</div>
</form>
<!-- scripts -->
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrap-filestyle.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/jquery.migrate.min.js"></script>
<script type="text/javascript" src="js/owl.carousel.min.js"></script>
<script type="text/javascript" src="js/jquery.isotope.min.js"></script>
<script type="text/javascript" src="js/jquery.fancybox.pack.js"></script>
<script type="text/javascript" src="js/jquery.fancybox-media.js"></script>
<script type="text/javascript" src="js/jquery.flot.js"></script>
<script type="text/javascript" src="js/jquery.flot.pie.js"></script>
<script type="text/javascript" src="js/jquery.flot.categories.js"></script>
<script type="text/javascript" src="js/greensock.js"></script>
<script type="text/javascript" src="js/layerslider.transitions.js"></script>
<script type="text/javascript" src="js/layerslider.kreaturamedia.jquery.js"></script>
<script type='text/javascript' src='js/jquery.velocity.min.js'></script>
<script type="text/javascript" src="js/jquery.slimscroll.min.js"></script>
<!-- Superscrollorama -->
<script type="text/javascript" src="js/jquery.superscrollorama.js"></script>
<script type="text/javascript" src="js/TweenMax.min.js"></script>
<script type="text/javascript" src="js/TimelineMax.min.js"></script>
<!--/ Superscrollorama -->
<script type="text/javascript" src="js/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.widget.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.tabs.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-tabs-rotate.js"></script>
<script type="text/javascript" src="js/jquery.ui.accordion.min.js"></script>
<script type="text/javascript" src="js/jquery.tweet.js"></script>
<!-- EASYPIECHART -->
<script type="text/javascript" src="js/jquery.easypiechart.js"></script>
<!--/ EASYPIECHART -->
<script type="text/javascript" src="js/intlTelInput.min.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery.autocomplete.min.js"></script>
<script type="text/javascript" src="js/preloader.js"></script>
<script type="text/javascript" src="js/scripts.js"></script>
<script type="text/javascript" src="js/moment.js"></script>
<script src="js/daterangepicker.js"></script>
<!--/ scripts -->
<script >
$("#MainContent_mobilenumber").intlTelInput({
});
$(function () {
$('#MainContent_txtDOB').daterangepicker({
singleDatePicker: true,
showDropdowns: true,
minDate: '01/01/1980',
maxDate: '12/31/2015'
});
});
$(function () {
//Hide label after 5 secs
setTimeout(function () {
$("[id$=textInfo]").fadeOut("slow");
}, 5000);
});
</script>
</body>
</html>
index.aspx.cs:
namespace Odiya_Doctor_Client
{
public partial class index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void doctorDetails_Click(object sender, EventArgs e)
{
Response.Write(txtDOB.Text.Trim());
}
}
}
当用户向DOB
字段提供任何输入并单击提交按钮时,它应显示但doctorDetails_Click
内的行显示为null。我需要在此处用户将插入应检索的任何值在提交按钮点击后的代码后端页面。请帮助我。
答案 0 :(得分:0)
更改
Response.Write(txtDOB.Text.Trim());
到
Response.Write(txtDOB.Text);