mardi 5 mai 2015

Jquery Tag it in asp.net

I am using jQuery UI widget Tag it. Code which i am using is working fine but all the Tag values visible on the browser.

Code I am using is below

    <script src="http://ift.tt/183v7Lz" type="text/javascript" charset="utf-8"></script>
    <script src="http://ift.tt/X4OQpz" type="text/javascript" charset="utf-8"></script>
      <script src="../JavaScript/tag-it.js"></script>
    <link href="../CSS/tagit.ui-zendesk.css" rel="stylesheet" />
    <link href="../CSS/jquery.tagit.css" rel="stylesheet" />
    <script>
        $(function(){
           var sampleTags = [<%# this.SuggestionList %>];
            //var sampleTags = ['c++', 'java', 'php', 'coldfusion', 'javascript', 'asp', 'ruby', 'python', 'c', 'scala', 'groovy', 'haskell', 'perl', 'erlang', 'apl', 'cobol', 'go', 'lua'];
            $('#myTags').tagit();         
            $('#singleFieldTags').tagit({
                availableTags: sampleTags,            
                allowSpaces: true,
                singleFieldNode: $('#mySingleField')
            });
           });
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div id="content">
            <p>              
                <input name="tags" id="mySingleField" value="Apple, Orange" disabled="true">
            </p>
            <ul id="singleFieldTags"></ul>
    </div> 
    </form>
</body>

Code behind

string queryString = "select * from SIB_KWD_Library ORDER BY Keyword asc";

    using (SqlConnection connection = new SqlConnection(ConfigurationManager.AppSettings["vConnString"].ToString()))
    {

        using (SqlCommand command = new SqlCommand(queryString, connection))
        {

            connection.Open();

            using (SqlDataReader reader = command.ExecuteReader())
            {

                while (reader.Read())
                {

                    if (string.IsNullOrEmpty(SuggestionList))
                    {
                        SuggestionList += "\'" + reader["Keyword"].ToString() + "\'";
                    }
                    else
                    {
                        SuggestionList += ", \'" + reader["Keyword"].ToString() + "\'";
                    }

                }
            }
        }
    }

In browser source code all the tag keywords are visible. Something like

var sampleTags = ['c++', 'java', 'php', 'coldfusion', 'javascript', 'asp', 'ruby', 'python', 'c', 'scala', 'groovy', 'haskell', 'perl', 'erlang', 'apl', 'cobol', 'go', 'lua'];

Please suggest any other way to do this.

Thanks in advance :)

Aucun commentaire:

Enregistrer un commentaire