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!

No comments:

Post a Comment