"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Thursday, May 20, 2010

time based redirection in asp.net

 Hi everybody,
This is a very useful one for every Project. A simple example is after registration v show a message after that a few second (Manually controlling) redirecting him to his home page.

        System.Threading.Thread.Sleep(5000); //  after 5 sec
        Response.Redirect("http://www.simplyasp.net");
//
i'm redirecting him to simplyasp.net

hope it help u some way's
Have a nice day... 'N happy Coding :)

 The Rough Guide to KeralaHidden India: The Kerala SpicelandsKerala Dream: A Shaman's Dream Project

Wednesday, May 19, 2010

Check RadioButton/CheckBox Depending Upon Data in DataBase

 hi eveybody,
Saving checked items in RadioButton/CheckBox  to database and showing that back like edit command.
For that i first saved that checked item in checkbox list to database by comma separated form like (TV,Fridge)

Storing data to database Which where items are checked
Code

            foreach (ListItem li in Chk_ItemList.Items)// here u will get all the item in the CheckBoxList
            {
                if (li.Selected == true)// here i filter the selected from the list
                {
                    _itemlist = _itemlist += li.Text + ","; //here i add the selected item one by one separated by comma ex:tv,coller
                }
            }

here
Chk_ItemList is my Checkboxlist id
_itemlist is a string where i storing my checked item
and normally storing to database :) .and show the content in a grid i chosen here a datagrid.

On displaying back Which where items are checked 
 i taken the SelectedIndexChanged event of grid and 

        string _Item = grd.SelectedItem.Cells[1].Text.ToString(); // here i'm getting the string TV,Fridge
        string[] Seperator = new string[] { "," }; //i define here which one is ti be eliminated from that string and i'm calling the split function
        string[] strsplitarr = _Item.Split(Seperator, StringSplitOptions.RemoveEmptyEntries);//
RemoveEmptyEntries is for remove blankspace from the string and storing that string in an array
        foreach (string _chkitem in strsplitarr)
        {
            Chk_ItemList.Items.FindByText(_chkitem).Selected = true;// by the help of foreach i'm taking all the entry of an array and finding the text in checkboxlist if i find i mark it as selected :)
        } 

'n i created a demo of it u can download that from here 

Have a nice day... 'N happy Coding :)

TitanicTitanic (10th Anniversary Edition)Titanic (Three-Disc Special Collector's Edition)

Monday, May 17, 2010

Pls wait... on submit button click in asp.net C#

Hi everybody,
One of the social website giving this feature i notice this stuff from their i feel pretty nice i done only on page load just like gmail.I done this by calling a javascript on server side on page load event i'm giving event name, no of second,button name, Display message  :)

Important 

"Match Every event with color"

lets move to coding
    protected void Page_Load(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(3000); but_sve.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(but_sve, "") + ";this.value='Please wait...';this.disabled = true;");
    }
    protected void but_sve_Click(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(5000); ClientScript.RegisterClientScriptBlock(this.GetType(), "reset", "document.getElementById('" + but_sve.ClientID + "').disabled=false;", true);
        lbl.ForeColor = System.Drawing.Color.Green;
        //lbl.Text = "Data Have Saved";
        Response.Redirect("http://www.google.com");//  from here ur coding can start
    }



U can download a demo from Here
Have a nice day... 'N happy Coding :)

SQL For DummiesSQL All-in-One Desk Reference For DummiesMicrosoft SQL Server 2008 For Dummies (For Dummies (Computer/Tech))