1

我只是想不通它为什么会犯这个错误。当我运行以下代码时。jquery 功能有效,但文本恢复到单击之前的状态。请帮助。

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="ViewListOfProjects.aspx.cs" Inherits="Final_Year_Project_Allocation_System.Stud.ViewListOfProjects" EnableSessionState="True" EnableViewState="False" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="SideBarContent" runat="server">
    <div class="well">
        <ul class="nav nav-list">
            <li class="nav-header">Student Menu</li>
            <li><a href="RegisterTeam.aspx">Home</a></li>
            <li><a href="student_project_choice.aspx">Select Project</a></li>
            <li class="active"><a href="ViewListOfProjects.aspx">View Project Proposal</a></li>
            <li><a href="ViewAllocatedProject.aspx">View allocated project</a></li>
            <li><a href="MscProjectProposalForm.aspx">Propose Project</a></li>
            <li><a href="ChangePassword.aspx">Change Password</a></li>
        </ul>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="BodyContent" runat="server">
        <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="navbar-inner">
            <div class="container-fluid">
                <a class="btn btn-navbar"></a><a class="brand" href="#">Project Allocation System</a>
                <div class="nav-collapse collapse">
                    <p class="navbar-text pull-right">
                        Logged in as
                        <asp:Label ID="lblUsername" runat="server"></asp:Label>
                        <asp:LinkButton ID="btnLogout" runat="server" onclick="btnLogout_Click">Logout</asp:LinkButton>
                    </p>
                </div>
            </div>
        </div>
    </div>
    <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
    <div class="pull-right">
    <asp:Label ID="lblPdf" runat="server" Text="View In PDF format" CssClass="label label-info"></asp:Label>
    <asp:ImageButton ID="btnPdf" 
            ImageUrl="~/Images/Adobe-PDF-Document-icon.png" Height="60px" Width="60px" runat="server" OnClientClick="redirect();"/>
    <br/><br/>
    </div>

<div id="pdfContent">
    <p></p>
</div>

<asp:PlaceHolder ID="projectHolder" runat="server"></asp:PlaceHolder> 

<script language="javascript" type="text/javascript">
    function redirect() {
        $('p').text("ss");
}

我希望文本包含 jquery 函数中的“ss”,并保持这种状态。

4

1 回答 1

3

尝试btnPdf像这样设置客户端点击:

OnClientClick="redirect(); return false;"
于 2013-05-19T07:32:35.620 回答