I am programatically reading data from a text input using standard Jquery like this:

我正在编程地使用标准Jquery从文本输入中读取数据,如下所示:

  var listName = $('#list').val();

and then I am adding a hidden input field into a form before submitting like this:

然后在提交之前,我在表单中添加了一个隐藏的输入字段:

var myForm = $("#myForm);
myForm.append('<input type="hidden" name="List" value="' + listName + '" />');

In one example, the value in the field is:

例如,字段中的值为:

Key Date & Times

so on the UI it looks like this

UI是这样的

<input type="hidden" name="MyList" value="Key Date & Times" />

when I submit the form using:

当我以下列方式递交表格:

var myForm = $("#myForm);
myForm.submit();

and check it on the asp.net-mvc server side i only see:

在asp.net-mvc服务器端,我只看到:

Key Date 

being sent over. After some research, it was suggested to write some javascript to run the value through:

发送结束。在一些研究之后,建议编写一些javascript来运行该值:

encodeURIComponent()

After doing that and taking a look at the server side, I now see:

这样做并查看服务器端之后,我现在看到:

Key%20Date%20%26%20Times

How can I convert that back to

我如何将它转换回

Key Date & Times

on the C# asp.net-mvc server side? Or Seperately, if I am doing something wrong on the client side, please let me if you have any suggestions.

在c# asp.net-mvc服务器端?另外,如果我在客户方面做错了什么,如果您有什么建议,请告诉我。

My main question is why do i have to worry about encoding the value of a hidden input box in a form. I would have thought this would be taken care of for you.

我的主要问题是,为什么我要担心在表单中编码隐藏输入框的值。我本以为你会处理好这件事的。

13 个解决方案

#1


11

string decodeString = HttpUtility.UrlDecode(@"Key%20Date%20%26%20Times");

Use UrlDecode method of HttpUtility class.

使用HttpUtility类的UrlDecode方法。

更多相关文章

  1. 在使用javascript将信息输入到输入字段时填充文本区域
  2. 更改html隐藏字段的事件
  3. ASP.NET下使用jQuery UI下的Dialog,服务器端按钮无响应的问题。
  4. Symfony 2在用户站点上动态添加字段以形成
  5. 如何在MVC4中使用type= " url "而不用jQuery将字段验证为url ?
  6. 使用表单字段值定制CSS属性。
  7. 我无法在某些Web浏览器中输入我的注册文本字段
  8. 将文本从表单复制到另一个网站的文本字段
  9. 我正在尝试使用带有post方法的AJAX将用户名和密码发送到php文件

随机推荐

  1. 设计模式之观察者模式
  2. 线程池你真不来了解一下吗?
  3. 多线程之死锁就是这么简单
  4. VSCode跳转到定义内部实现_VSCode插件开
  5. ES2018
  6. TypescriptServerPlugin_VSCode插件开发
  7. Taro
  8. Android(安卓)源码导入Eclipse技巧(Ubuntu
  9. Android(安卓)调用摄像头功能【拍照与视
  10. 选中菜单android中的显示跳转和隐式跳转