我已经下载了一个html5模板,并开始通过ASP.Net 4.5进行开发
我在注册页面的这个项目中有一个简单的按钮!
当我使用完整的网址(http://mydomain.com/signup/default.aspx)加载页面时,一切正常!但是当我想用(http://mydomain.com/signup/)加载页面时,我的Button的OnClick
事件不会触发!!
让我感到困惑!有谁可以帮助我?!
答案 0 :(得分:0)
这是我的default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="SalaamSocial.signup._default" %>
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="ie lt-ie9 lt-ie8 lt-ie7 app footer-sticky"> <![endif]-->
<!--[if IE 7]> <html class="ie lt-ie9 lt-ie8 app footer-sticky"> <![endif]-->
<!--[if IE 8]> <html class="ie lt-ie9 app footer-sticky"> <![endif]-->
<!--[if gt IE 8]> <html class="ie app footer-sticky"> <![endif]-->
<!--[if !IE]><!-->
<html class="app footer-sticky">
<!-- <![endif]-->
<head>
<title></title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<!--
**********************************************************
In development, use the LESS files and the less.js compiler
instead of the minified CSS loaded by default.
**********************************************************
<link rel="stylesheet/less" href="/assets/less/admin/module.admin.stylesheet-complete.sidebar_type.discover.less" />
-->
<!--[if lt IE 9]><link rel="stylesheet" href="/assets/components/library/bootstrap/css/bootstrap.min.css" /><![endif]-->
<link rel="stylesheet" href="/assets/css/admin/module.admin.stylesheet-complete.sidebar_type.discover.min.css" />
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<script src="/assets/components/plugins/ajaxify/script.min.js?v=v1.9.6&sv=v0.0.1"></script>
<script>var App = {};</script>
<script data-id="App.Scripts">
App.Scripts = {
/* CORE scripts always load first; */
core: [
'/assets/components/library/jquery/jquery.min.js?v=v1.9.6&sv=v0.0.1',
'/assets/components/library/modernizr/modernizr.js?v=v1.9.6&sv=v0.0.1'
],
/* PLUGINS_DEPENDENCY always load after CORE but before PLUGINS; */
plugins_dependency: [
'/assets/components/library/bootstrap/js/bootstrap.min.js?v=v1.9.6&sv=v0.0.1',
'/assets/components/library/jquery/jquery-migrate.min.js?v=v1.9.6&sv=v0.0.1'
],
/* PLUGINS always load after CORE and PLUGINS_DEPENDENCY, but before the BUNDLE / initialization scripts; */
plugins: [
'/assets/components/plugins/nicescroll/jquery.nicescroll.min.js?v=v1.9.6&sv=v0.0.1',
'/assets/components/plugins/breakpoints/breakpoints.js?v=v1.9.6&sv=v0.0.1',
'/assets/components/plugins/preload/pace/pace.min.js?v=v1.9.6&sv=v0.0.1',
'/assets/components/plugins/less-js/less.min.js?v=v1.9.6&sv=v0.0.1',
'/assets/components/modules/admin/charts/flot/assets/lib/excanvas.js?v=v1.9.6&sv=v0.0.1',
'/assets/components/plugins/browser/ie/ie.prototype.polyfill.js?v=v1.9.6&sv=v0.0.1'
],
/* The initialization scripts always load last and are automatically and dynamically loaded when AJAX navigation is enabled; */
bundle: [
'/assets/components/core/js/preload.pace.init.js?v=v1.9.6',
'/assets/components/core/js/core.init.js?v=v1.9.6',
'/assets/components/core/js/animations.init.js?v=v1.9.6'
]
};
</script>
<script>
$script(App.Scripts.core, 'core');
$script.ready(['core'], function () {
$script(App.Scripts.plugins_dependency, 'plugins_dependency');
});
$script.ready(['core', 'plugins_dependency'], function () {
$script(App.Scripts.plugins, 'plugins');
});
$script.ready(['core', 'plugins_dependency', 'plugins'], function () {
$script(App.Scripts.bundle, 'bundle');
});
</script>
<script>if (/*@cc_on!@*/false && document.documentMode === 10) { document.documentElement.className += ' ie ie10'; }</script>
<script type="text/javascript" src="/assets/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
var isvalid;
var emailValid;
$(document).ready(function () {
$("#txtFirstName").change(function (event) {
validateRegisterForm($(event.target).attr('id'));
});
$("#txtLastName").change(function (event) {
validateRegisterForm($(event.target).attr('id'));
});
$("#txtEmailAddress").change(function (event) {
validateRegisterForm($(event.target).attr('id'));
});
$("#txtPassword").change(function (event) {
validateRegisterForm($(event.target).attr('id'));
});
$("#txtConfirmPassword").change(function (event) {
validateRegisterForm($(event.target).attr('id'));
});
});
function validateRegForm() {
validateRegisterForm("btnSignUp");
var mainbtn = $telerik.findButton("<%= btnSignUp1.ClientID %>");
if (isvalid) mainbtn.click();
}
function ProfileImageUploaded(sender, args) {
alert(args.get_fileName());
}
function validateRegisterForm(senderId) {
var lblErrText = $("#lblErrText");
//alert(senderId);
var txtFirstName = $("#txtFirstName");
var txtLastName = $("#txtLastName");
var txtEmailAddress = $("#txtEmailAddress");
var txtPassword = $("#txtPassword");
var txtConfirmPassword = $("#txtConfirmPassword");
isvalid = false;
var rev = document.getElementById("regularEmailAddress");
if (txtEmailAddress.val() != "" && (senderId == "btnSignUp" || senderId == "txtEmailAddress")) {
ValidatorValidate(rev);
}
if (txtFirstName.val() == "" && (senderId == "btnSignUp" || senderId == "txtFirstName")) {
lblErrText.text("لطفا نام خود را وارد کنید!");
txtFirstName.focus();
}
else if (txtLastName.val() == "" && (senderId == "btnSignUp" || senderId == "txtLastName")) {
lblErrText.text("لطفا نام خانوادگی خود را وارد کنید!");
txtLastName.focus();
}
else if (txtEmailAddress.val() == "" && (senderId == "btnSignUp" || senderId == "txtEmailAddress")) {
lblErrText.text("لطفا آدرس ایمیل خود را وارد کنید!");
txtEmailAddress.focus();
}
else if (!rev.isvalid && (senderId == "btnSignUp" || senderId == "txtEmailAddress")) {
lblErrText.text("آدرس ایمیل وارد شده معتبر نمی باشد!");
txtEmailAddress.focus();
}
else if (txtPassword.val() == "" && (senderId == "btnSignUp" || senderId == "txtPassword")) {
lblErrText.text("لطفا رمز عبور خود را وارد کنید!");
txtPassword.focus();
}
else if (txtPassword.val() != txtConfirmPassword.val() && (senderId == "btnSignUp" || senderId == "txtConfirmPassword")) {
lblErrText.text("تکرار رمز عبور اشتباه وارد شد!");
txtConfirmPassword.focus();
}
else {
isvalid = true;
}
if (isvalid) $("#divErr").slideUp(300);
else {
$("#divErr").slideDown(300);
}
$("#btnSignUp").blur();
}
</script>
</head>
<body class="scripts-async loginWrapper">
<!-- Main Container Fluid -->
<div class="container-fluid menu-hidden">
<!-- Content -->
<div id="content">
<div class="layout-app">
<!-- row-app -->
<div class="row row-app">
<!-- col -->
<!-- col-separator.box -->
<div class="col-separator col-unscrollable box">
<form id="form1" runat="server">
<telerik:RadScriptManager ID="scriptmanager1" runat="server"></telerik:RadScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="panelMain">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="panelMain" LoadingPanelID="RadAjaxLoadingPanel1">
</telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="MetroTouch" IsSticky="true"
Style="position: fixed; top: 0; left: 0; height: 100%; width: 100%; z-index:999999999;">
</telerik:RadAjaxLoadingPanel>
<!-- col-table -->
<asp:Panel ID="panelMain" runat="server">
<div class="col-table">
<h4 class="innerAll margin-none border-bottom text-center bg-primary">
<i id="iIcon" runat="server" class="fa fa-pencil"></i>
<asp:Label ID="lblHeaderText" runat="server"></asp:Label>
</h4>
<!-- col-table-row -->
<div class="col-table-row">
<!-- col-app -->
<div class="col-app col-unscrollable">
<!-- col-app -->
<div class="col-app">
<div class="login">
<%--<div class="placeholder text-center"><i class="fa fa-pencil"></i></div>--%>
<div class="innerAll margin-none text-center">
<img src="/assets/images/logo/salam_aleyk_2.png" class="border-none" />
</div>
<div id="divErr" class="panel panel-default col-sm-8 col-sm-offset-2" style="display: none;">
<div class="panel-body right_dir" style="color: #EB6A5A;">
<asp:Label ID="lblErrText" runat="server"></asp:Label>
</div>
</div>
<asp:Panel ID="panel1" runat="server" Visible="false" DefaultButton="btnSignUp">
<div class="panel panel-default col-sm-6 col-sm-offset-3">
<div class="panel-body">
<div class="form-group">
<label for="txtFirstName" class="right_float">نام</label>
<asp:TextBox ID="txtFirstName" runat="server"
onchange="validateRegisterForm()"
CssClass="form-control right_dir"></asp:TextBox>
</div>
<div class="form-group">
<label for="txtLastName" class="right_float">نام خانوادگی</label>
<asp:TextBox ID="txtLastName" runat="server"
CssClass="form-control right_dir"></asp:TextBox>
</div>
<div class="form-group">
<label for="txtEmailAddress" class="right_float">آدرس ایمیل</label>
<asp:TextBox ID="txtEmailAddress" runat="server"
CssClass="form-control"></asp:TextBox>
<asp:RegularExpressionValidator ID="regularEmailAddress" runat="server"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ValidationGroup="signUp" ControlToValidate="txtEmailAddress"></asp:RegularExpressionValidator>
</div>
<div class="form-group">
<label for="txtPassword" class="right_float">رمز عبور</label>
<asp:TextBox ID="txtPassword" runat="server"
TextMode="Password"
CssClass="form-control"></asp:TextBox>
</div>
<div class="form-group">
<label for="txtConfirmPassword" class="right_float">تکرار رمز عبور</label>
<asp:TextBox ID="txtConfirmPassword" runat="server"
TextMode="Password"
CssClass="form-control"></asp:TextBox>
</div>
<asp:Button ID="btnSignUp" runat="server"
CssClass="btn btn-primary btn-block"
OnClientClick="validateRegForm();return false;"
Text="ساخت اکانت" />
<telerik:RadButton ID="btnSignUp1" runat="server"
style="display:none;"
ValidationGroup="signUp"
PostBackUrl="default.aspx"
OnClick="btnSignUp_Click"></telerik:RadButton>
</div>
</div>
</asp:Panel>
<asp:Panel ID="panel2" runat="server" Visible="false">
<div class="panel panel-default col-sm-8 col-sm-offset-2">
<div class="panel-body">
<telerik:RadAsyncUpload ID="radUpload1" runat="server" HideFileInput="true" OnClientFileUploaded="ProfileImageUploaded">
</telerik:RadAsyncUpload>
<telerik:RadProgressArea ID="progress1" runat="server">
<ProgressTemplate>
<div style="width:100%; padding:20px; background-color:#2b5364; font-family:Tahoma; font-size:12px; text-align:center; color:#fff;">
در حال بارگذاری تصویر
</div>
</ProgressTemplate>
</telerik:RadProgressArea>
<div style="text-align: center;">
<img src="../assets/images/people/no_user_pic.png" class="border-none" />
</div>
<asp:Button ID="btnUploadImage" runat="server"
CssClass="btn btn-info btn-block"
OnClick="btnSignUp_Click"
Text="بارگذاری تصویر" />
<asp:LinkButton ID="btnSkipProfileImage" runat="server" Text="فعلا بیخیال!" OnClick="btnSkipProfileImage_Click"></asp:LinkButton>
</div>
</div>
</asp:Panel>
<asp:Panel ID="panel3" runat="server" Visible="false">
<div class="panel panel-default col-sm-6 col-sm-offset-3">
<div class="panel-body">
<div class="form-group">
<label for="txtFirstName" class="right_float">شماره تماس</label>
<asp:TextBox ID="txtPhoneNumber" runat="server"
onchange="validateRegisterForm()"
CssClass="form-control right_dir"></asp:TextBox>
</div>
<div class="form-group">
<label for="txtLastName" class="right_float">شغل</label>
<asp:TextBox ID="TextBox2" runat="server"
CssClass="form-control right_dir"></asp:TextBox>
</div>
<div class="form-group">
<label for="txtEmailAddress" class="right_float">تاریخ تولد</label>
<asp:TextBox ID="TextBox3" runat="server"
CssClass="form-control"></asp:TextBox>
</div>
<asp:Button ID="Button1" runat="server"
CssClass="btn btn-primary btn-block"
OnClick="btnSignUp_Click"
Text="تکمیل پروفایل" />
</div>
</div>
</asp:Panel>
<div class="clearfix"></div>
</div>
</div>
<!-- // END col-app -->
</div>
<!-- // END col-app.col-unscrollable -->
</div>
<!-- // END col-table-row -->
</div>
<!-- // END col-table -->
</asp:Panel>
</form>
</div>
<!-- // END col-separator.box -->
</div>
<!-- // END row-app -->
</div>
</div>
</div>
<!-- Global -->
<script data-id="App.Config">
var basePath = '',
commonPath = '/assets/',
rootPath = '/',
DEV = false,
componentsPath = '/assets/components/',
layoutApp = true,
module = 'admin';
var primaryColor = '#eb6a5a',
dangerColor = '#b55151',
successColor = '#609450',
infoColor = '#4a8bc2',
warningColor = '#ab7a4b',
inverseColor = '#45484d';
var themerPrimaryColor = primaryColor;
</script>
</body>
</html>
这是我的default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NikWebSiteManager;
using Telerik.Web.UI;
namespace SalaamSocial.signup
{
public partial class _default : PageClass
{
DataLayer.UsersTableAdapters.UsersTableAdapter UsersTableAdapter = new DataLayer.UsersTableAdapters.UsersTableAdapter();
private string PageAction
{
get
{
return QueryString.Decode("action");
}
}
protected void Page_Load(object sender, EventArgs e)
{
form1.Action = Request.RawUrl;
if (PageAction == "")
{
panel1.Visible = true;
}
else if (PageAction == "profileImage")
{
panel2.Visible = true;
btnSkipProfileImage.PostBackUrl = "default.aspx?" + Request.QueryString.ToString();
}
}
protected void btnSignUp_Click(object sender, EventArgs e)
{
string email = txtEmailAddress.Text.ToLower().Trim();
if (NikWebStrings.CheckCorrectEmail(email))
{
UsersTableAdapter.Insert(email, NikWebStrings.HashMD5(txtPassword.Text), txtFirstName.Text, txtLastName.Text, "", true, CurrentDateTime);
int userId = UsersTableAdapter.GetUserId(email).Value;
Response.Redirect("?q=" + QueryString.Encode(new string[] { "action", "userId" }, new string[] { "profileImage", userId.ToString() }));
}
else
{
}
}
}
}