ah..it does not hit the breakpoint. and the script error is displayed only when I try to check the checkbox, not when the page loads.
Dynamically populating a DropDownList, AutoPostback and JavaScript error
Collapse
X
-
Okay, it sounds like the JavaScript that preforms the AutoPostback is not working.
I don't know why this would be the case. The only thing that I can think of is that your JavaScript is somehow invalid (maybe you didn't close the <script> tag?) But your JavaScript looks fine.
Try removing your JavaScript from the page.
Do you get the same error?
What web browser are you using? What version is it?
Are you using Ajax?
If so are you using any Ajax enabled controls?
These may be causing a problem...
-FrinnyComment
-
Hi Frinny
Thank you for your quick responses.
I did try to remove the javascript from the page. it still gives me the error. I am currently using IE7 and I do not have any ajax controls.
I did try to create a new checkbox list and even that gives me the same error.
I created a new page and could figure out the how to create a dropdown when a checkbox is selected. It works fine. But my original page still has the error for the autopostback.
Your help is greatly appreciated.
Thank you...Comment
-
It's too bad that you were having such a hard time with your original page.
At least the error isn't happening on your new aspx page.
So, in the method that handles the AutoPostback for the CheckBoxList (list??) you need to create list items for your DropDownList based on what was checked/selected.
(I'm not sure what language you're using.)
There are two ways to do this. You can create generate ListItem objects and add them to your DropDownList's "Items" property. Or you can bind your DropDownList to a data source.
-FrinnyComment
-
Ah, sorry I miss-read your response.
You have figured out how to dynamically populate your DropDownList.
Contrats!
:)
I have no idea what is wrong with your page.
I can't see you page so....I'm kind of in the dark here.
The only reasons that I can think of is that there is some sort of invalid JavaScript or Ajax on the page that is breaking the code that normally preforms the AutoPostback.
Stuff like not closing the script tag or leaving out a curly brace ("}") or something.
If you want to debug your original page, and you don't want to move your code into the new page, then (...I think I'm going to regret asking for this but...) please post the entire ASPX page code. **winces**
-FrinnyComment
-
Thank you.
But I am afraid I wont be able to post the aspx code as it has many fields that are pulled from a database.
Anyway, I will try to move my code once I figure out a small issue that i have with my new page.
My new issue, as mentioned earlier I have a checkbox list. But checking only one box should enable the dropdown.
For example,
- Web
- Employees
- Newspaper
- Other
As it is a checkbox list, a user can select any number of checkboxes. BUt my dropdwon should be enabled only when newspapers is checked.I see that whenever I select more than two checkboxes, the CheckBoxList1.S electedValue still has only one value. For example a user selects both web and newspaper, but the dropdown is not enabled as CheckBoxList1.S electedValue is Web.
In my CheckBoxList1_S electedIndexCha nged, I am using
Code:if (CheckBoxList1.SelectedValue == "NewsPaper"){//enable dropdown}
Any help would be greatly appreciated.
Please let me know if I am not clear.Comment
-
Loop through each item in the CheckBoxList and check if it is "NewsPaper" and if it is selected.
The thing is that the CheckBoxList is going to post back every time a check box is checked within it. Make sure you check to see if the DropDownList is already populated.
-FrinnyComment
-
Hello Frinny
Thanks for all the help. I have accomplished all the required functionality. But still my script error exists, I tried to transfer my original page code to a new page...and again the script error pops up...still struggling to find out the cause.Comment
-
Hurray, my code is working.
I had a sumbit button in my page with id='submit' and I did change the small letter 's' to capital letter 'S' and it working like a charm..
It was a silly thing but dont know why it caused the problem. Have found this solution online after hours of searching.
Thought this could help someone like me.Comment
Comment