Showing posts with label empty. Show all posts
Showing posts with label empty. Show all posts

Wednesday, March 21, 2012

ModalPopUp - Getting value from DropDownList

I have a dropdownlist in my modal pop up and when I click the submit button the page posts back but DropDownList.SelectedValue is empty. I need that value so that I can submit to the database when the btnSubmit_Click method is fired.

My modal extender:

<atlasToolkit:ModalPopupExtenderID="ModalPopupExtender_AddEntity"runat="server"><atlasToolkit:ModalPopupPropertiesTargetControlID="imgBtn_AddEntity"DropShadow="true"PopupControlID="pnlAddEntityModal"CancelControlID="btnCancelEntity"BackgroundCssClass="modalBackground"OkControlID="btnAddEntity"/></atlasToolkit:ModalPopupExtender>

My Submit button:

<

asp:Buttonid="btnAddEntity"Width="110"runat="server"Text="Submit"CssClass="button"OnClick="btnSubmit_Click"UseSubmitBehavior="false"/>Might you be hitting the issue outlined in the following post:http://forums.asp.net/thread/1316941.aspx?

Actually I was able to solve the problem using this bit of Javascript and C#. BUT, it seems that the selected value of the dropdownlist is not always there. It seems a littl buggy. Can someone look at my code and let me know if I am missing something:

<scripttype="text/javascript">var selectedEntity;var selectedProperty;//var selectedValues;function onOk() {

selectedEntity = document.getElementById(

'ddlEntity').value +"-" + document.getElementById('ddlProperty').value;//selectedProperty = document.getElementById('ddlProperty').value;//selectedValues = selectedEntity + "-" + selectedProperty;

__doPostBack(

'btnAddEntity',selectedEntity);

}

</script>

<atlasToolkit:CascadingDropDownID="CascadingDropDown1"runat="server"><atlasToolkit:CascadingDropDownPropertiesTargetControlID="ddlEntity"Category="Entity"PromptText="<-- Selected an Entity -->"ServicePath="webservices/ws_Timetracking.asmx"ServiceMethod="GetEntites"/><atlasToolkit:CascadingDropDownPropertiesTargetControlID="ddlProperty"ParentControlID="ddlEntity"PromptText="<-- Select a Property -->"ServiceMethod="GetPropsForEntity"ServicePath="webservices/ws_Timetracking.asmx"Category="Property"/></atlasToolkit:CascadingDropDown>

<atlasToolkit:ModalPopupExtenderID="ModalPopupExtender_AddEntity"runat="server"><atlasToolkit:ModalPopupPropertiesTargetControlID="imgBtn_AddEntity"DropShadow="true"PopupControlID="pnlAddEntityModal"CancelControlID="btnCancelEntity"BackgroundCssClass="modalBackground"OkControlID="btnAddEntity"OnOkScript="onOk()"/></atlasToolkit:ModalPopupExtender>

Sorry, I'm not seeing the empty SelectedValue issue on my end with the recent 60626 release. If you still see it with that release, could you please post a small, simple example of the problem so we can look into it further? Thanks!


You're talking about the AtlasControlKit release, right? I have 1.0.60504.0. Do I just download the lastest version and Add Reference to the AtlasControlKit.dll into my project?

Yes, the AtlasControlToolkit release 60626 which can be downloaded from here:http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=AtlasControlToolkit&ReleaseId=70

You download it and extract the files and you'll see an environment very much like the 60504 release, except with additional controls, some fixes, automated testing, etc.. You should be able to substitute the new 60626 versions of AtlasControlToolkit.dll and Microsoft.AtlasControlExtender.dll for the old 60504 versions without any problems. Just remove the references to the old DLLs and add references to the new ones and you should be set!

ModalPopup and empty Listbox

I'm running into an issue where I have an empty listbox within a ModalPopup window. For some reason, the Listbox shows up with an XX appearing in it. The XX is not a ListItem as it is not selectable and can't be edited or removed via code. I even tried to add a ListItem and then clear the Listbox, but clearing the ListBox results in the XX showing up again.

Has anyone else run into this? Is this a known bug? Any workaround?

Thanks in advance,

Matt

I had a similar issue: I tried to put an asp:Button control in a ModalPopup and assign a method to it - it appeared, but didn't perform the desired code. Instead I tried a plain-ole HTML button control and assigned a javascript function similar to what I wanted it to do and it worked.

Later, on ScottGu's blog,he posted the new release of the toolkit and in the post there was mention of the Modal having some updates/fixes performed to it, specifically in regard to positioning, however, I thought I saw somewhere something about the use of server side controls. Hmm... I'll keep looking and update you if I find more.

In the interim, are you able to use a client-side listbox and see if that resolves anything? Or does your LB need to be databound or what? Can you show us some code to see if we can spot anything simple that you may have overlooked (as we all do at times)?

regards,
(bs.)



Thanks for the reply. The listbox does need to be databound in certain circumstances, so the client-side won't work.

Strange, though ... noticing the 'XX' in FireFox 1.5 but not in IE or FF 2.0. Grrrrrrrrrrrrrr ......


Hi,

I tried it on FF 2.0.0.4, this problem still exists. It's hard to tell the exact cause, but you can solve it by adding an item to it when there is no items in the list.

For example:

function pageLoad()
{
var list = $get("ListBox1");

if(list.options.length < 1)
{
list.options.add(new Option(""));
}
}

Hope this helps.