使用jQuery [英] Using jQuery

查看:37
本文介绍了使用jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery显示消息框,但出现错误.

下面是代码.

I am using jQuery to display a message box, but it gives an error.

Below is the code.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_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 runat="server">
    <title>Untitled Page</title>
    <script src="App_Data/jquery.js"type="text/javascript"></script>
    <script src="App_Data/jquery-impromptu.3.1.js"type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div style="height: 348px">
    </div>
    </form>
</body>
</html>


现在* .cs文件后面的代码:


Now the code behind *.cs file:

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        showmsg("Example1");
    }
    public void showmsg(string str)
{
    string prompt = "<script>$(document).ready(function(){{$.prompt('{0}!',{1});}});</script>";
    string message = string.Format(prompt, str, "{ prefix: 'impromptu' }");
    // registering the JavaScript on the page and controls with postback
    this.Page.ClientScript.RegisterStartupScript(typeof(Page), "alert", message);
}
}


请协助.


Please assist.

推荐答案

(document).ready(function(){{
(document).ready(function(){{


.prompt('{0}! ',{1});}});</script>"; 字符串 message = 字符串.Format(提示,str," {前缀:'impromptu'}"); // 在页面上注册JavaScript并使用回发控件 .Page.ClientScript.RegisterStartupScript( typeof (页面)," ,消息); } }
.prompt('{0}!',{1});}});</script>"; string message = string.Format(prompt, str, "{ prefix: 'impromptu' }"); // registering the JavaScript on the page and controls with postback this.Page.ClientScript.RegisterStartupScript(typeof(Page), "alert", message); } }


请协助.


Please assist.


我猜想,您的脚本无法加载,原因是它们保存在"App_Data"文件夹中(Asp.net工作进程可能没有权限.在该文件夹上).要验证这一点,请将两个JQuery 脚本存储在另一个文件夹中(例如,"scripts"),然后在Aspx页面中更新脚本路径.即:

I guess, your scripts are failing to load due to the fact that these are maintained within the "App_Data" folder (The Asp.net worker process may not have permission on that folder). To verify that, store the two JQuery scripts inside a different folder (Say, "scripts") and update the script paths in the Aspx page. That is:

<script src="scripts/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="scripts/jquery-impromptu.3.1.min.js" type="text/javascript"></script>



如果现在在页面输出中看到所需的消息,则意味着您的Asp.net工作进程缺少对"App_Data"文件夹的读取权限. (您也可以在浏览器中点击javascript的直接URL,以验证浏览器是否可以加载这些脚本).如果是这样,则需要为工作进程(或运行Asp.net应用程序的用户帐户)分配足够的权限,并确保浏览器可以在URL中加载这些脚本.这应该可以解决您的问题.



If you see the desired message in the page output now, that means, your Asp.net worker process lacks enough read permission on the "App_Data" folder. (You can also hit a direct URL of the javascripts in the browser to verify whether browser can load these scripts). If that is so, you need to assign enough permission on the worker process (Or, on the user account under which the Asp.net application is running) and make sure that your browser can load those scripts in the URL. This should solve your problem.


这篇关于使用jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆