首页 \ 问答 \ 在stringbuilder中的Javascript(Javascript with in stringbuilder)

在stringbuilder中的Javascript(Javascript with in stringbuilder)

我根据需要转换了这段代码

http://jquerymsgbox.ibrahimkalyoncu.com/

大家好我已经编写了以下代码来显示警报

public static string ShowAlertMessage(string pHeader, string pError, Page page)
{
    //StringBuilder sb = new StringBuilder();
    StringBuilder strScript = new StringBuilder();

    strScript.Append("<script type='text/javascript' src='Scripts/jquery-1.4.1.js'>");
    strScript.Append("</script>");
    strScript.Append("<script type='text/javascript' src='Scripts/jquery.msgBox.js'>");
    strScript.Append("</script>");
    strScript.Append("<link href='Styles/msgBoxLight.css' rel='stylesheet' type='text/css'>");
    strScript.Append("</link>");
    strScript.Append("<script type='text/javascript'>");
    strScript.Append("function example()");
    strScript.Append("{");
    strScript.Append("$msgBox({");
    strScript.Append("title:" + pHeader + "");
    strScript.Append(",");
    strScript.AppendLine("content:" + pError + "");
    strScript.Append("});");
    strScript.Append("}");
    strScript.Append("</script>");
    page.ClientScript.RegisterStartupScript(page.GetType(), "Script", strScript.ToString(), true);
    return strScript.ToString();
}

但这并没有给我预期的输出可以帮助我在哪里出错

这是生成的字符串构建器

<script type='text/javascript' src='Scripts/jquery-1.4.1.js'></script>
<script type='text/javascript' src='Scripts/jquery.msgBox.js'></script>
<link href='Styles/msgBoxLight.css' rel='stylesheet' type='text/css'></link>
<script type='text/javascript'>
function example()
{
   $msgBox({title:Testing Code,
   content:Hello
 });
}
</script>

This code I converted as per needed

http://jquerymsgbox.ibrahimkalyoncu.com/

Hi all I have written the following code to display an alert

public static string ShowAlertMessage(string pHeader, string pError, Page page)
{
    //StringBuilder sb = new StringBuilder();
    StringBuilder strScript = new StringBuilder();

    strScript.Append("<script type='text/javascript' src='Scripts/jquery-1.4.1.js'>");
    strScript.Append("</script>");
    strScript.Append("<script type='text/javascript' src='Scripts/jquery.msgBox.js'>");
    strScript.Append("</script>");
    strScript.Append("<link href='Styles/msgBoxLight.css' rel='stylesheet' type='text/css'>");
    strScript.Append("</link>");
    strScript.Append("<script type='text/javascript'>");
    strScript.Append("function example()");
    strScript.Append("{");
    strScript.Append("$msgBox({");
    strScript.Append("title:" + pHeader + "");
    strScript.Append(",");
    strScript.AppendLine("content:" + pError + "");
    strScript.Append("});");
    strScript.Append("}");
    strScript.Append("</script>");
    page.ClientScript.RegisterStartupScript(page.GetType(), "Script", strScript.ToString(), true);
    return strScript.ToString();
}

But this is not giving me the expected output can some one help me where I went wrong

This is the generated string builder

<script type='text/javascript' src='Scripts/jquery-1.4.1.js'></script>
<script type='text/javascript' src='Scripts/jquery.msgBox.js'></script>
<link href='Styles/msgBoxLight.css' rel='stylesheet' type='text/css'></link>
<script type='text/javascript'>
function example()
{
   $msgBox({title:Testing Code,
   content:Hello
 });
}
</script>

原文:https://stackoverflow.com/questions/16885123
更新时间:2023-12-25 12:12

最满意答案

List是引用列表。 如果从一个列表中获取引用并将其添加到另一个列表,则两个列表都引用同一对象

如果您获得对此类对象的引用并对其进行变更(设置字段),则更改将反映在两个列表的相关元素中。


A List is a list of references. If you get a reference from one list and add it to another list, both lists have references to the same object.

If you get a reference to such an object and mutate it (set a field), the change will be reflected in the relevant element of both lists.

相关问答

更多
  • 你的理解是完全错误的 key的整个目的是为了ordering而不是rendering 。 图像中有项目a,b,c,d,并通过开关a和c重新排序,即c,b,a,d。 没有密钥,就很难做出反应来弄清楚如何从旧的虚拟DOM转换到新的虚拟DOM。 请阅读此https://facebook.github.io/react/docs/lists-and-keys.html Your understanding is completely wrong The whole purpose of key, is for or ...
  • 在您的程序中,数据结构的name字段被定义为pointer 。 因此,当你strcpy ,会有内存损坏,因为没有为pointer分配空间。 因此,要么malloc为每个节点的name空间,要么将name定义为n元素的数组。 In your program, the name field of your data structure is defined to be a pointer. Hence, when you strcpy, there will be memory corruption as no ...
  • List是引用列表。 如果从一个列表中获取引用并将其添加到另一个列表,则两个列表都引用同一对象 。 如果您获得对此类对象的引用并对其进行变更(设置字段),则更改将反映在两个列表的相关元素中。 A List is a list of references. If you get a reference from one list and add it to another list, both lists have references to the same object. If you get a ref ...
  • 因为你正在使用.append(''); ,每次更改时,都会将新选项添加到现有列表中。 相反,你可以使用: .html(''); // remove old options 要重置select并删除旧选项,请使用: .append(''); // add new o ...
  • 对问题2的回答: 转到顶部功能区上的列表 - >列表选项卡 - >工作流设置 - >在SharePoint Designer中创建工作流。 在工作流程中添加名称 - >确定。 将设置更改为仅在更改项目时启动。 添加操作“更新列表项” - >单击“此列表” 选择“列表:当前项目” - >单击“添加” 在“设置此字段:”中选择标题列; 在“To this value:”中点击“...” 在“字符串生成器”对话框窗口中单击“添加或更改查找” 数据来源:当前项目; 来自源的字段:您的标题列 - >确定 它看起来像这 ...
  • 使用myList.setHandlesInput(true); 在您的活动代码中。 Use myList.setHandlesInput(true); in your event code.
  • 你做的是一个浅拷贝。 浅复制和深复制之间的区别仅与复合对象(包含其他对象的对象,如列表或类实例)相关: 浅拷贝构造一个新的复合对象,然后(尽可能)将引用插入到原始对象中。 深层复制构造一个新的复合对象,然后递归地将复制插入原始对象中的对象。 你想要做什么来创建一个全新的对象,以便不会干扰其他对象。 以下是如何进行深层复制。 import copy a = [[1, 1], [2, 2], [3, 3]] b = copy.deepcopy(a) a[0][0] = 100 print(a) print(b ...
  • 要仅打印未更改的文件,请使用: git ls-files -v | grep '^[[:lower:]]' 你可以按日期等排序。希望它有所帮助。 To print just the files that are unchanged use: git ls-files -v | grep '^[[:lower:]]' You can than sort them by date etc. Hope it helps.
  • 在w2ui 1.5中,您可以使用$jQueryElement.w2field()来访问w2fild对象 - 然后对其进行操作。 例: var field = $("#my_input").w2field(); field.options.items = ["my", "new", "items"]; // optionally: pre-select first item field.setIndex(0); // if you do NOT use "setIndex" you need to call ...
  • 您正在添加对一个原始obj()实例的引用: self.pos.append(self.pos[men]) 那不是副本; 这只是对同一个对象的另一个引用。 改为创建一个新的 obj()实例: self.pos.append(obj(self.pos[men].x, self.pos[men].y)) You are adding references to your one original obj() instance: self.pos.append(self.pos[men]) That's no ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。