0

我遇到了一个非常奇怪的情况。我有两页Default.aspxRegistration.aspx. 最初加载默认页面。有一个按钮Default.aspx,当用户单击此按钮时会触发一个 javascript 函数,在 JS 函数中,我只是使用 将他重定向到第二页window.location

如果我form runat="server"在 Default.aspx 页面中包含标签,则不会发生重定向。相反,它会在用户单击按钮后重定向到同一页面,即 Default.aspx。但是,如果我form runat="server"从默认页面中删除标签,那么它的工作正常。

以下是代码Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Temp_Default" %>

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="css/style.css" />

<script src="script/Script_Default_Page.js"></script>

</head>

<body>
<form runat="server">
<div class="headerContainer">
    <div class="header_wraper">
        <div class="Headernav">
            <a href="#">Contact us</a>
            <a href="#">FAQ</a>
            <a href="#">Projects</a>
            <a href="#">About us</a>
            <a href="#" class="select">Home</a>
            <br clear="all" />
            Welcome
        </div>
        <a href="#" class="float_left"><img src="images/logo.png" alt="Pakistan" /></a>
        <br clear="all" />
    </div>
</div>
<div class="sliderContainer">
    <div class="sliderWraper">
        <img src="images/slider_img.jpg" class="float_right" alt="" />
        <div class="sliderText">
            <h1>
            <div class="sliderBtns">
                <a href="#" class="select"></a>
                <a href="#"></a>
                <a href="#"></a>
                <br clear="all" />
            </div>
        </div>
        <br clear="all" />
    </div>
</div>
<div class="postContainer">
    <div class="postWraper">
        <div class="postBox">
            <div class="postText">
                <b>Maryam Aminah</b>
                <p>This is Photoshop's version  of Lorem Ipsum. Proin gravida nibh vel velit auctor aliquet. Aenean sollicitudin, lorem quis bibendum auctor, nisi elit consequat ipsum, nec sagittis sem nibh id elit. </p>
            </div>
            <img src="images/post_img1.png" alt="" />
            <br clear="all" />
        </div>
        <div class="postBox">
            <div class="postText">
                <b>Asad Khawaja</b>
                <p>This is Photoshop's version  of Lorem Ipsum. Proin gravida nibh vel velit auctor aliquet. Aenean sollicitudin, lorem quis bibendum auctor, nisi elit consequat ipsum, nec sagittis sem nibh id elit. </p>
            </div>
            <img src="images/post_img2.png" alt="" />
            <br clear="all" />
        </div>
        <div class="postBox border_non margin_r_zero">
            <div class="postText">
                <b>Sonia Waqas</b>
                <p>This is Photoshop's version  of Lorem Ipsum. Proin gravida nibh vel velit auctor aliquet. Aenean sollicitudin, lorem quis bibendum auctor, nisi elit consequat ipsum, nec sagittis sem nibh id elit. </p>
            </div>
            <img src="images/post_img3.png" alt="" />
            <br clear="all" />
        </div>
        <br clear="all" />
    </div>
</div>
<div class="bottom_Container">
    <div class="rightSide">
        <div class="searchBox">
            <a href="#" class="SearchBtn" ><img src="images/search_btn.png" alt="" /></a>
            <input type="text" class="SearchTextBox" value="Search Profiles..." />
        </div>
        <button id="ReserveSpaceBtn" class="reservebtn" onclick="showdiv('popup');">Reserve Space</button>
      <div class="postInfo">
            <div class="postInfoName">
                <img src="images/Aseer_img1.png" alt="" />
                <b>Asser Malik</b>
                <br clear="all" />
            </div>
            <div class="mamngmnt">
                Management Trainee - Commercial at <b>Coca-Cola Beverages, Pakistan</b>
            </div>
            <div class="mamngmnt study">
                Studied at <b>Lahore University of Management Sciences</b>
            </div>
            <div class="mamngmnt location">Lives in <b>Lahore, Pakistan</b></div>
            <input type="text" class="aboutPakistan" value="About Pakistan" />
            <p>This is Photoshop's version  of Lorem Ipsum. Proin gravida nibh vel velit auctor aliquet. Aenean sollicitudin, lorem quis bibendum auctor, nisi elit consequat ipsum, nec sagittis sem nibh id elit. Duis sed odio sit amet nibh vulputate cursus a sit amet mauris. </p>
            <p><a href="#"><img src="images/back_btn.png" alt="" /></a></p>
        </div>
    </div>

    <div class="map">   
        <span><img src="images/map.png" alt="" /></span>
        <div class="footer">
            <a href="#"><img src="images/brand1.png" alt="" /></a>
            <a href="#"><img src="images/brand2.png" alt="" /></a>
            <a href="#"><img src="images/brand3.png" alt="" /></a>
            <a href="#"><img src="images/brand4.png" alt="" /></a>
            <a href="#"><img src="images/brand5.png" alt="" /></a>
            <a href="#"><img src="images/brand6.png" alt="" /></a>
            <a href="#"><img src="images/brand7.png" alt="" /></a>
        </div>
    </div>
    <div class="addBox">
        <b>Global Stats*</b>
        <span><img src="images/down_img.png" alt="" /></span>
        <span><img src="images/loader.png" alt="" /></span>
        <b>Project Milestones</b>
        <span><img src="images/down_img.png" alt="" /></span>
        <span><img src="images/add_img.png" alt="" /></span>
        <b>Goal:</b>
        <p>Teach 20 Children</p>
    </div>
</div>
</form>

这是在按钮单击时触发的 JS 函数定义:

function showdiv(id) {
window.location = "Registration.aspx";
}

谁能指出问题出在哪里?这是我第一次遇到这个问题。

谢谢。

4

0 回答 0