Monday, March 26, 2012

modal popup in repeater

hi, i just would like to know if it is possible that there is only one modal popup in the page where i have a repeater. to make it clear, let me explain. for example, i have 10 items in dynamically populated using the repeater, i want their names to be a link or a link button. then when i click on the name of the item 1, there will be a modal popup that will appear, then when i click item 2, that same modal popup will appear. i understand that when using modal popup in a page, it will look for the control that will trigger the modal popup, but in this instance, i want to populate that modal popup with the data depending on the item that i click. will this be possible?thank you in advance.

Yes its possible. Please ModalPopupExtender alongwith your itemtemplate

<asp:RepeaterID="Repeater1"runat="server"DataSourceID="LinqDataSource1">

<ItemTemplate>

<asp:LinkButtonID="lnkButton"runat="server"Text="Show Popup"></asp:LinkButton>

<ajaxToolkit:ModalPopupExtenderID="mp1"runat="server"TargetControlID="lnkButton"PopupControlID="pnlModal">

</ajaxToolkit:ModalPopupExtender>

</ItemTemplate>

</asp:Repeater>

Hope it helps


hi, thank you for the reply. i believe i will be using one panel for this. now, if i have 50 records on the page, does it mean it will also generate 50 modalpopup extenders?


No, that would be a terrible waste...

Usemp1.Show() and mp1.Hide()in code behind to show or hide the popup..

aspx in pseudo:

targetcontrolID = hiddenButtonID

<panel>

<updatepanel>[contents of modal popup]</updatepanel>

</panel>

<modalextender... />

code behind:

Protected sub DoThis()

populateDetails()

updatepanel.Update()

modalextenderID.Show()

End sub

Hope it's clear...


i thought so. do you have an sample source code that i can look into? thank you.


thank you for the reply. should i make an event handler for this? if yes, how can i do it? sorry, really new to asp.net.


No,

you should use (bold)

<asp:LinkButtonID="lnkButton"runat="server"Text="Show Popup"OnClick="DoThis"></asp:LinkButton>

No comments:

Post a Comment