Click here to Skip to main content
15,896,421 members
Articles / Programming Languages / Javascript

VisualJS.NET custom control development

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
14 Nov 2012CPOL4 min read 16.5K   198   13  
How to use custom JavaScript controls under VisualJS.NET.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; 
using VisualJS;
using VisualJS.Web.Forms;
using System.Linq;
using System.Text;

namespace SpinnerTest.VisualJSApp
{
    public partial class FormInElement : VisualJS.Web.Forms.Form
    {

        public FormInElement()
        {
            InitializeComponent();
        } 

        //Use the below constructor if you create the instance of this Form object other than the active Thread
        //otherwise you will receive "Cant locate the ClientID in active context. Consider using Form constructor with ClientID parameter" exception
        public FormInElement(string clientId): base(clientId)
        {
            InitializeComponent(); 
        }

        private void jButton1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Thanks for your feedback!", this);
        }

        private void textBox1_OnSuggestion(string value)
        {
            Dictionary<string, string> list = new Dictionary<string, string>();
            string [] words = value.Split(' ');
            foreach (string word in words)
            {
                if (word.ToLower().StartsWith("po"))
                {
                    list.Add("PokeIn", Color.DarkGreen.ToWebColor());
                    list.Add("Power", Color.Maroon.ToWebColor());
                    list.Add("Posix", Color.DarkBlue.ToWebColor());
                }
                else if (word.ToLower().StartsWith("vi"))
                {
                    list.Add("VisualJS.NET", Color.Black.ToWebColor());
                    list.Add("Visual C++", Color.Brown.ToWebColor());
                    list.Add("Visual Basic", Color.YellowGreen.ToWebColor());
                }
            }

            if (list.Count > 0)
                textBox1.UpdateSuggestion(list);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Poland Poland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions