Thursday, September 29, 2011

how to start thread ?

using System;

using System.Threading;

public class ThreadTest {

    public void csharpeMethod() {

        int result = 1;

        Console.WriteLine(result.ToString() + "  Thread ID is  " +

                          AppDomain.GetCurrentThreadId().ToString());

    }

    public static void Main() {

        ThreadTest objThread = new ThreadTest ();

        objThread.csharpeMethod();

        ThreadStart objts = new ThreadStart(objThread.csharpeMethod);

        Thread obj = new Thread(objts);

        obj.Start();

    }

}


Sunday, September 25, 2011

Use Viewstate with UpdatePanel in asp.net

ViewState Can not use with UpdatePanel in ASP.NET Because When Page is not postBack at time viewstate is Available and If  Page is PostBack at time viewstate kill (Destroy). Now New ViewState is Generate that is used by On in Update Panel What is Solution fo viewstate? Solution is that make EnableViewState="true" in UpdatePanel. Put Hidden Filed in UpdatePanel and store Value in Hidden Field. Problem is Solve. Now If You want to use JavaScript Function Then you can Register That JavaScript Function in UpdatePanel Load Event
protected void UpdatePanel1_Load(object sender, EventArgs e)
{
   // Add client-side script to call the JavaScript  function
   ScriptManager.RegisterStartupScript(this, this.GetType(),
                  Guid.NewGuid().ToString(),
                  "YourJAVASCRIPTfunctionName();", true);
}   
ASPdotNET-Example