February 2006 - Posts - Developers Anonymous

February 2006 - Posts

Everytime I run an ASP.Net2 project it starts Mozilla instead of IE!!!

Mozilla isn't my default browser, and I cannot find the option to switch the option!

must investigate this!
Man did I battle with this!

Thank goodness I've got a great boss who taught some things I didn't know about HTML to help me out.

Basically, I wanted add/remove items to an arrayList when selected. Adding wasn't a problem at all. Removing on the other-hand. I'm pretty new to VS2005 and common sense says that functionality for controls should stay the same. Not anymore!!!!

If I uncheck something then chkList.SelectedIndex.Selected should return false. BUT it was always returning true, because it was automatically moving the seleted index to the index of an item that was selected.

So, to get the currently selectedIndex you need to fetch the __EventTarget of that Postback. This is done by accessing the Request.Form[0] or Request.Form["__EVENTTARGET"] object. This tells the page what object was selected. It returns the following value:

chklstSelect$7

chklstSelect is the ID of the CheckListBox object and the $ is the separator. The 7 is the Index that was selected. Then just declare a string and fill it with the :
Request.Form[0].ToString();

THEN remove all the characters up to and including the $ sign:

vSelectedIndex = vSelectedIndex.Remove(0, vSelectedIndex.LastIndexOf("$") + 1);

then convert the string to an Interger:

int vIndex = Int32.Parse(vSelectedIndex);

Now that we have the Index we set the current SelectIndex for the CheckListBox as follows and check whther the object selected. If it isn't then removed those values from my two ArrayLists.:

//Select that Item via its index and check its current property
if (!(chklstSelect.Items[vIndex].Selected))
{
    //Remove entry from the array
    vDescArray.Remove(chklstSelect.Items[vIndex].Text);
    vIDArray.Remove(chklstSelect.Items[vIndex].Value);    
}

Glad thats finally over. I hope this helps someone else as googling this topic did NOTHING for me!
I've got a check list box with about 20 checkboxes.

So when one is clicked, if it is unchecked i want to do something.

onSelectedIndexChanged_click(blah blah)
{
    if (!(chklstSelect.Items[chklstSelect.SelectedIndex].Selected))
        {
            //do want i want          
        }
}


AM I JUST BEING A N00B OR IS THIS CHECKLISTBOX NOT WORKING?!?!?!?!?!

I'M FREAKING OUT!!!!
Hey guys,

Is it poosible to use a variable as a column name in SQL?

EXAMPLE:

DECLARE @TEST VARCHAR(100)

SET @TEST = 'NAME'

SELECT @TEST
FROM TABLE1

Quiet obviously I'm getting the value of @test back eachtime. I'm 99% sure its possible but my googling so far hasn't turned up anything.
We are currently updating all our HTML and JAVAScript to conform to W3C standards and one thing has had me baffled for a while.

We dynamically generate an HTML Table and thus dynamically add onclick events via javascripting.

now, in IE to remove a row from the HTML table you just say,

table.removeNode(NodeID)

BUT

in mozilla

table.deleteRow(NodeID.rowIndex)
My first VS2005 bug ;)

More User error actually. My project would not start and it said It could not load the assembly!

After looking around for a minute or two I noticed that my Project name was Steven's First.

Oops! simply changed it to Stevens First and went fine. n00b error.