表单runat标记导致重定向到同一页面

时间:2013-09-18 11:16:15

标签: javascript html .net visual-studio-2010

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

如果我在Default.aspx页面中包含form runat="server"标记,则不会发生重定向。相反,它会在用户单击按钮后重定向到同一页面,即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";
}

有人能指出问题所在吗?这是我第一次遇到这个问题。

感谢。

0 个答案:

没有答案