Sunday, 15 June 2014

Copy to clipboard in asp.net c# code behind

using namespace-  System.Windows.Form

protected void btn_copyadd_Click(object sender, EventArgs e)

    {
        string addrs="Your text here"
        Val = addrs;
        System.Threading.Thread staThread = new System.Threading.Thread(new                                        System.Threading.ThreadStart(myMethod));
        staThread.ApartmentState = System.Threading.ApartmentState.STA;
        staThread.Start();
        lbl_title.Text = "Address";
        lbl_messages.Text = addrs;

        ModalAlert.Show();
}

 private static string _Val;
    public static string Val
    {
        get { return _Val; }
        set { _Val = value; }
    }
    public static void myMethod()
    {
        System.Windows.Forms.Clipboard.SetText(Val);

    }

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...