在一个小的asp.net webclient中,我有以下Ajax调用.
$.ajax({
type: "GET",
url: "Search.aspx?action=GetDocumentInfoByChronicleId&" + querystring
})
.success(function (msg) {
$("#documentcontent").html(msg);
})
Run Code Online (Sandbox Code Playgroud)
querystring默认字符的工作原理但在使用特殊字符时似乎不起作用(参见下面的示例)
objectId=09028139800c59e3&Db=DIV_Firm <== Works
objectId=090281>>773c5983&Db=DIV_Firm <== Non Working
Run Code Online (Sandbox Code Playgroud)
基于此(以及更多关于SO的帖子我选择改变我的ajax调用如下(EncodeUriComponent).但似乎没有一个工作(即使使用原始的查询字符串).
有人能向我指出我做错了什么吗?
$.ajax({
type: "GET",
url: "Search.aspx?action=GetDocumentInfoByChronicleId&" + encodeURIComponent(querystring)
})
.success(function (msg) {
$("#documentcontent").html(msg);
})
Run Code Online (Sandbox Code Playgroud)
注意: EncodeUri似乎工作正常.但我更喜欢使用EncodeUriComponent
这可能是一个非常简单的问题,但谷歌让我失望,并一直指向我的python解决方案.
我有一个applciations/users可以提供的网页querystringparameters.要检索查询字符串参数,我使用以下代码:
IDictionary<string, string> qStrings = HtmlPage.Document.QueryString;
Run Code Online (Sandbox Code Playgroud)
检查指定密钥的存在,我使用以下代码:
if (!String.IsNullOrEmpty(qStrings["PARAM1"]))
{}
Run Code Online (Sandbox Code Playgroud)
了解我们的用户,我希望他们给出如下参数键:"Param1","param1","pArAm1"如何简单地将字典中的每个键转换为大写而不迭代每个键值对?
或者我怎么能改变它qStrings["PARAM1"]所以它忽略了这个案子?
我目前有一个看起来有点如下的List(Of String)名字docIds:
{A3001,A40001,BF0003,13458}
Run Code Online (Sandbox Code Playgroud)
它只包含字母和数字.我想输出该数组如下(用于DQL查询)
'A3001','A40001','BF0003','13458'
Run Code Online (Sandbox Code Playgroud)
当然我使用的String.Join方法
String.Join(",",docIds.ToArray())
Output: A3001,A40001,BF0003,13458
Run Code Online (Sandbox Code Playgroud)
我知道添加这些引号的2种(非性能)方法
String.Join,iterate在列表中的每个字符串,并添加引号.方法2:以下String操作:
"'" + String.Join(",",docIds.ToArray()).Replace(",","','") + "'"
Run Code Online (Sandbox Code Playgroud)问题:是否有更高效/正确的方法来达到预期效果?
如果之前已经问过这个问题,我很抱歉,但到目前为止,我的stackoverflow搜索并没有给我带来我需要的答案.在不确定的时间间隔,我的JavaScript正在接收包含HTML的字符串.
一个简单的例子:
<p class='commentator'>Person A</p> Comment of Person A <br/> <p class='commentator'> Person B </p> Comment of person B
Run Code Online (Sandbox Code Playgroud)
当满足某些条件时,<p>应从字符串中删除所有标记及其内容.我知道如何<p>使用以下代码删除标记:
stringComments= stringComments.replace(/<\/?p[^>]*>/g, "");
Run Code Online (Sandbox Code Playgroud)
如何修改该正则表达式以包含<p>标签的内容?(regex= .*?)
我的预期产量应如下:
Comment of Person A <br/> Comment of person B
Run Code Online (Sandbox Code Playgroud)
注意:那些引用jQuery的remove().这不会起作用,首先因为它不是DOM的一部分而且其次我必须将这些更改限制在这个字符串中.
我以前在我的代码中有以下类
public class SomeListClass
{
public List<Boolean> ListA {get; set;}
public List<Boolean> ListB {get; set;}
public List<String> ListStringsA {get; set;}
public List<String> ListStringsB {get; set;}
public List<String> ListStringsC {get; set;}
public List<String> ListStringsD {get; set;}
public void InitLists()
{
ListStringsA = ListStringsB = ListStringsC = ListStringsD = new List<String>();
ListA = ListB = new List<Boolean>();
}
}
Run Code Online (Sandbox Code Playgroud)
我注意到使用这个初始化和下面的代码:
SomeListClass itm = new SomeListClass();
itm.InitLists();
itm.ListStringsA.Add("TestString");
itm.ListA.Add(true);
Run Code Online (Sandbox Code Playgroud)
ListStringsA,那么它只会被添加到ListStringsAListA它会自动添加到ListB结果将是:
ListStringsA = {"TestString"}
ListStringsB = …Run Code Online (Sandbox Code Playgroud) 最初我有一个像这样的删除功能:
function ViewWorkflowDetail(btn, workflowId) {
$("#workflowDetailPanel").remove();
if (document.getElementById("workflowDetailPanel") == null) {
// Do something usefull here
}
}
Run Code Online (Sandbox Code Playgroud)
哪个工作得非常出色.然而(本着尽可能多地使用JQuery的精神)我将其改为:
function ViewWorkflowDetail(btn, workflowId) {
$("#workflowDetailPanel").remove();
if ($("#workflowDetailPanel") == null) {
// Do something usefull here
}
}
Run Code Online (Sandbox Code Playgroud)
但是现在$("#workflowDetailPanel")永远不再是空的了.如果我再次改回它(to document.getElementById),那么就没有问题了.为什么第二个选项继续找到那个div?JQuery对象是否以某种方式维护在某种缓存中?
注意:完全相同的设置/数据用于测试两种情况.