文本框不提取字符(如&和,) [英] Text box does not fetch characters (like & and ,)

查看:79
本文介绍了文本框不提取字符(如&和,)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<script type="text/javascript">

    function openEditorWindow(forumID) {
        var oReadingWnd = radopen("~/AddArchives.aspx?id=" + forumID);
        oReadingWnd.Center();
    }
</script>
<script type="text/javascript">
    function GetTextBoxValue() {

        var hyp = document.getElementById('<%= JournalName.ClientID %>');

        var hyp1 = document.getElementById('<%= hplAddAcrhives.ClientID %>');
        //alert(hyp.innerHTML + 'su' + hyp.innerText);
        hyp.innerHTML = 'New Text';
        //alert(hyp.innerHTML);
        hyp1.href = 'AddArchives.aspx?JournalName=' + (hyp.value);
    }







和超链接 -






and hyperlink -

<asp:HyperLink ID="hplAddAcrhives"  BackColor="WhiteSmoke"

                                            Font-Bold="True" CssClass="fancybox iframe" runat="server" onClick= "javascript:GetTextBoxValue();">Add Archives</asp:HyperLink>

example - suppose if i pass JOURNAL & RESEARCH from query string ... than text box fetch only JOURNAL

Plz help me .. How to solve this problem

推荐答案

您需要对查询字符串进行编码。 &符号中的&符号表示它是一个新参数。



在C#中,您可以使用Sever.UrlEncode对查询字符串进行编码。然后在JS中使用decodeURIComponent()对其进行解码。
You need to encode your querystring. An ampersand & in the querystring means it is a new parameter.

In C# you can use Sever.UrlEncode to Encode the querystring. Then in JS you use decodeURIComponent() to decode it.


通过javascript使用此URL进行URL编码并传递给url

-------- ----------------------------------------------



Use this for URL Encode by javascript and pass to url
------------------------------------------------------

encodeURIComponent(strURL);





使用此代码将解码URL代码转换为您想要移动的页面

--- -------------------------------------------------- -





Use this for Decode URL code to Page which u want move
-------------------------------------------------------

HttpUtility.UrlDecode(url)


这篇关于文本框不提取字符(如&amp;和,)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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