Click here to Skip to main content
15,891,951 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: how to control asp.net control position at run time Pin
Not Active5-Mar-10 4:00
mentorNot Active5-Mar-10 4:00 
GeneralRe: how to control asp.net control position at run time Pin
developerit5-Mar-10 5:31
developerit5-Mar-10 5:31 
GeneralRe: how to control asp.net control position at run time Pin
Not Active5-Mar-10 5:36
mentorNot Active5-Mar-10 5:36 
QuestionChat service Pin
Subin Mavunkal4-Mar-10 23:42
Subin Mavunkal4-Mar-10 23:42 
AnswerRe: Chat service Pin
Sandeep Mewara7-Mar-10 6:55
mveSandeep Mewara7-Mar-10 6:55 
QuestionRadioButtonList and CheckBoxList Pin
Besa724-Mar-10 20:39
Besa724-Mar-10 20:39 
AnswerRe: RadioButtonList and CheckBoxList Pin
s.mn5-Mar-10 6:41
s.mn5-Mar-10 6:41 
GeneralRe: RadioButtonList and CheckBoxList Pin
Besa726-Mar-10 5:13
Besa726-Mar-10 5:13 
The reason the control postsbacks is just by developing reasons. When it is done it will not work like that. But the finished page will work like that anyway although you wont see it. I will try to explain:

1. When I click the "next question" button the page_load runs again.
2. In the page_load the querysting checks the number of the question
3. the question is loaded from the databse
4. In the database there is a field for random on/off.
5. The checkedlistbox webcontrol object is created.
6. If random - random values are created and put into a list (in this case the list could look liek this: 2, 0, 1)
7. The name of the towns are added into the checkedlistbox as listitems, the order of the listitems is added like this:

for (int i = 0; i < this.LstChkBoxes.Count; i++)
{
myCheckBoxList.Items.Add(new ListItem(this.LstChkBoxes[lstRandom[i]].sText, this.LstChkBoxes[lstRandom[i]].nAlternatives.ToString()));
}

8. The webcontrol is then added into the panel on the webpage, but in a different order than before. In the radiobutton-case the selection is attached to the choice on the second rendering of the page, but not in the checkboxcase.

This is the code that creates the webcontrol CheckBoxList



public override WebControl ToWebControl()
        {
            myCheckBoxList = new CheckBoxList();

            myCheckBoxList.BackColor = ColorTranslator.FromWin32((int)CrBkColor);
            myCheckBoxList.Style.Add("Position", "Absolute");
            myCheckBoxList.Style["Top"] = ITop.ToString() + "px";
            myCheckBoxList.Style["Left"] = ILeft.ToString() + "px";
            myCheckBoxList.Style.Add("z-index", this.Order.ToString());
            myCheckBoxList.ID = this.checkboxId.ToString();
            myCheckBoxList.AutoPostBack = true;

            if (this.BRandomShow)
            {

                Random rand = new Random();

                
                List<int> lstRandom = new List<int>();
                while (nmbrsAdded == false)
                {
                    int rnd1 = rand.Next(0, this.LstChkBoxes.Count);

                    if (!lstRandom.Contains(rnd1))
                    {
                        lstRandom.Add(rnd1);
                        if (lstRandom.Count == this.LstChkBoxes.Count)
                            nmbrsAdded = true;
                    }
                }
                for (int i = 0; i < this.LstChkBoxes.Count; i++)
                {
                    myCheckBoxList.Items.Add(new ListItem(this.LstChkBoxes[lstRandom[i]].sText, this.LstChkBoxes[lstRandom[i]].nAlternatives.ToString()));
                }


            }
            else
            {
                for (int i = 0; i < this.LstChkBoxes.Count; i++)
                {
                    myCheckBoxList.Items.Add(new ListItem(this.LstChkBoxes[i].sText, this.LstChkBoxes[i].nAlternatives.ToString()));
                }
            }
            if (this.bBorder)
            {
                myCheckBoxList.BorderStyle = BorderStyle.Solid;
                myCheckBoxList.BorderColor = Color.Black;
                myCheckBoxList.BorderWidth = Unit.Pixel(2);
            }



            if ((Lwfont.LocalFontStyle & 1) != 0)
                myCheckBoxList.Font.Bold = true;
            if ((Lwfont.LocalFontStyle & 2) != 0)
                myCheckBoxList.Font.Italic = true;
            if ((Lwfont.LocalFontStyle & 4) != 0)
                myCheckBoxList.Font.Underline = true;
            if ((Lwfont.LocalFontStyle & 8) != 0)
                myCheckBoxList.Font.Strikeout = true;

            if (this.lwfont.LocalFontName != null)
            {
                myCheckBoxList.Font.Name = this.Lwfont.LocalFontName.ToString();
                myCheckBoxList.Font.Size = lwfont.LocalFontSize;
                myCheckBoxList.ForeColor = ColorTranslator.FromWin32((int)Lwfont.LocalFontColor);
            }
            else
            {
                Test test = new Test();
                test = HttpContext.Current.Session["test"] as Test;
                myCheckBoxList.Font.Name = test.SfontName;
                myCheckBoxList.ForeColor = ColorTranslator.FromWin32((int)test.IfontColor);
            }
            int height = this.IBottom - this.ITop;
            int width = this.IRight - this.ILeft;

            myCheckBoxList.Width = width;
            myCheckBoxList.Height = height;
            return myCheckBoxList;
        }

GeneralRe: RadioButtonList and CheckBoxList Pin
s.mn7-Mar-10 23:46
s.mn7-Mar-10 23:46 
GeneralRe: RadioButtonList and CheckBoxList Pin
Besa728-Mar-10 21:58
Besa728-Mar-10 21:58 
AnswerRe: RadioButtonList and CheckBoxList Pin
edge116-Mar-10 2:50
edge116-Mar-10 2:50 
Questioni want some demo of asp.net project for online mobile shoppy Pin
poonam jagdale4-Mar-10 19:32
poonam jagdale4-Mar-10 19:32 
AnswerRe: i want some demo of asp.net project for online mobile shoppy Pin
ko__marek4-Mar-10 19:52
ko__marek4-Mar-10 19:52 
AnswerRe: i want some demo of asp.net project for online mobile shoppy Pin
ko__marek4-Mar-10 19:54
ko__marek4-Mar-10 19:54 
QuestionValidatingreader is obsolete Pin
ishwarya mahadevan4-Mar-10 18:40
ishwarya mahadevan4-Mar-10 18:40 
Questionlightbox with other information Pin
Tridip Bhattacharjee4-Mar-10 18:37
professionalTridip Bhattacharjee4-Mar-10 18:37 
QuestionDatetime Pin
4anusha44-Mar-10 18:35
4anusha44-Mar-10 18:35 
AnswerRe: Datetime [modified Pin
Dinesh Mani4-Mar-10 18:55
Dinesh Mani4-Mar-10 18:55 
GeneralRe: Datetime [modified Pin
4anusha44-Mar-10 19:32
4anusha44-Mar-10 19:32 
AnswerDatetime Pin
Manish_Kumar_Nayak6-Mar-10 0:46
Manish_Kumar_Nayak6-Mar-10 0:46 
AnswerRe: Datetime Pin
carlecomm7-Mar-10 14:48
carlecomm7-Mar-10 14:48 
QuestionGraph/Chart control Pin
Tufail Ahmad4-Mar-10 18:08
Tufail Ahmad4-Mar-10 18:08 
AnswerRe: Graph/Chart control Pin
Pranay Rana4-Mar-10 19:00
professionalPranay Rana4-Mar-10 19:00 
GeneralRe: Graph/Chart control Pin
Tufail Ahmad4-Mar-10 19:11
Tufail Ahmad4-Mar-10 19:11 
GeneralRe: Graph/Chart control Pin
Pranay Rana4-Mar-10 19:30
professionalPranay Rana4-Mar-10 19:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.