Showing posts with label enter. Show all posts
Showing posts with label enter. Show all posts

Monday, March 26, 2012

Modal Popup OnClick (Server Side) Issues

I'm utilizing a modal popup to allow a user to enter a new record for a gridview on the screen. Once the modal popup is displayed (via clicking a link button), the user enters some values in some textboxes and the user clicks the save button. At this point the application executes the code in the code-behind for the button. However, if this is the first viewing of the screen (i.e. I just pressed play in visual studio), the values of the textboxes contained within the panel contain blank values (even though the user entered values).

The second strange thing that occurs, is if this is not the first viewing of this page and I click the link to display the modal popup, enter the text and click save, the OnClick (server side) fires twice.

Has anyone run across this issue? If so, how did you resolve it?

Thanks in advance,

Brian

Please try your scenario with the recently available61106 release of the Toolkit (and ASP.NET AJAX Beta 2). If the problem persists, then please reply with acomplete, self-contained sample page that demonstrates the problem so that we can investigate the specific behavior you're seeing. Thank you!

If you are using the Official Beta 2 release - don't use it (As David recommended) - unless they updated the bits on the day they posted it as Beta 2 Release -its broke...- go to the source tab and download today's release...about 1/3 of the controls with the 'official Beta 2 ' release would exhibit that behavior (the accordian - would never accept user clicks, drag panel never dragged, always visible just remained visible in one spot, and the modal exhibited your issues... had something to do with types function or something...If you are using Beta 1 or Atlas - it will be more about how you are wrapping the modal - you should place it in its own update panel even if you are attaching it into every row. I personally have the modal as a single instance and I control the modal show and hide in codebehind... examples are in my blog entries...

Wednesday, March 21, 2012

ModalPopup add rows to datagrid

I am trying to have a ModalPopupExtender when a button is clicked on the main page. On the popup, a user can enter a couple of peices of information and click the add button. I have that part working, but I am trying to make it more dynamic. Does anyone know how to make it so:

1) The popup doesn't disppear after clicking the add button, so the user can add more than one row without having to click the button on the main page

2) The datagrid is updated withwout postback

I have tried using the UpdatePanel, but I keep geeting an error message: An extender can't be in a different UpdatePanel than the control it extends.

Here is my code from the page:

<asp:ScriptManagerID="ScriptManager1"runat="server">

</asp:ScriptManager>

<table><tr><td><asp:ButtonID="ButtonAddItem"runat="server"Text="Button"/></td></tr>

<tr><td>

<asp:DataGridID="DataGridTemplate"runat="server"AutoGenerateColumns=falseDataKeyField="ItemID"BorderStyle=NoneBorderWidth=0>

<Columns>

<asp:BoundColumnDataField="ItemDescr"></asp:BoundColumn>

<asp:BoundColumnDataField="TimeFrame"></asp:BoundColumn>

</Columns>

</asp:DataGrid>

</td></tr></table>

<asp:PanelID="PanelAddTemplateItem"runat="server"style="display:none;"CssClass="modalPopup">

<table>

<tr><tdcolspan=2>Add Line Item</td></tr>

<tr><td>Line Item:</td><td><asp:TextBoxID="TextBoxAddTemplate"runat="server"TextMode=MultiLine></asp:TextBox></td></tr>

<tr><td>Time Frame:</td><td><asp:TextBoxID="TextBoxAddTemplateTime"runat="server"></asp:TextBox></td></tr>

<tr><tdcolspan=2><asp:LabelID="LabelAddTemplate"runat="server"></asp:Label></td></tr>

<tr><td><asp:ButtonID="ButtonAddTemplate"runat="server"Text="Add"/></td><td><asp:ButtonID="ButtonAddTemplateOK"runat=serverText="finished"/></td></tr>

</table>

</asp:Panel>

<ajaxToolkit:ModalPopupExtenderID="ModalPopupExtenderAddTemplateLine"runat="server"TargetControlID="ButtonAddItem"PopupControlID="PanelAddTemplateItem"CancelControlID="ButtonAddTemplateOK"BackgroundCssClass="modalBackground"DropShadow=true>

</ajaxToolkit:ModalPopupExtender>

I was able to figure out my first problem by putting the updatepanel inside the asp:panel that the modalpopupextender displays. However, I still cannot seem to figure out how to update the datagrid. Is it possible to update the grid on-screen without a postback? Thanks!


Hi Briancostea,

I think you should add another UpdatePanel to your page and remove the DataGrid into the newly added UpdatePanel.So now there are two UpdatePanels. When we add new records, one UpdatePanel will be postback and add data to Database or somewhere else and next the another UpdatePanel will be refreshed. To refresh the UpdatePanel's content , please use add these code to your page.

 <script type="text/javascript" language="javascript"> var eventButton; Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler); Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); function BeginRequestHandler(sender, args){ eventButton=args.get_postBackElement().id } function EndRequestHandler(sender, args){ if(eventButton =="Button1" ){ //refresh UpdatePanel2 by using __doPostBack() state. } } </script>

I hope this help.

Best regards,

Jonathan