Showing posts with label repeater. Show all posts
Showing posts with label repeater. Show all posts

Monday, March 26, 2012

Modal Popup In A Repeater

Hi,

Is there a way to use the ModalPopupExtender from inside a repeater -- each item would have a "delete" link button, and on clicking this, the Panel should be shown? Ive tried everything I can think of, but am not getting anywhere.

Thanks

Joe

Hmmm, I have seen modalpopupextender in the repeater before and it worked fine. Do you get any javascript errors, run-time errors about the extender setup, and how are you wiring the extender to the actual button that will cause the pop up to appear?


The ToolkitTests\Manual\DataboundDynamicPopulate.aspx file that comes with the Toolkit includes a ModalPopup in a repeater (DataList).


Thanks for the heads up. Between this and another article I found (sorry, cant find it right now to give credit), I came up with the solution I was looking for.

My solution is here (for my future reference): http://blog.joelowrance.com/archive/2007/07/10/ajax-modalpopupextender-in-a-repeater.aspx


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>

Wednesday, March 21, 2012

ModalPop-Up

Hello,

On my web form I have a repeater control which has a link button as the ItemTemplate.

<asp:RepeaterID="rptMyFavoriteReports"runat="server"OnItemCommand="rptMyFavoriteReports_ItemCommand">

<ItemTemplate>

<asp:ImageID="Image1"runat="server"<b><%#DataBinder.Eval(Container.DataItem,"ReportName") %></b> (<ahref="#"class="anchor">More Information</a>)

<asp:Linkbuttonid="lnkBtn"runat="server"CssClass="anchor">Remove</asp:Linkbutton><br/>

</ItemTemplate>

</asp:repeater>

When the user clicks on this link button the Modal Pop-up should show up. When i set the the modal pop-up extender properties as TargetControlsID="linkbutton:

<atlasTools:ModalPopupExtenderID="ModalPopupExtender1"runat="server">

<atlasTools:ModalPopupProperties

TargetControlID="lnkBtn"

PopupControlID="Panel1"

OkControlID="OkButton"

CancelControlID="CancelButton"

OnOkScript="OnOK()"/>

</atlasTools:ModalPopupExtender>

i get the following error.

Object reference not set to an instance of an object.

NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.AtlasControlExtender.ExtenderControlBase`2.ConnectDataBindingHandlers() +276
Microsoft.AtlasControlExtender.ExtenderControlBase`2.OnInit(EventArgs e) +45
System.Web.UI.Control.InitRecursive(Control namingContainer) +459
System.Web.UI.Control.InitRecursive(Control namingContainer) +271
System.Web.UI.Control.InitRecursive(Control namingContainer) +271
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1739

Any sugesstion how to over come this.

Thanks!!

Hi Radhikap,

Try putting the whole extender inside the repeater's ItemTemplate.

Thanks,
Ted

Hello Ted,

It worked like a charm Thank you

Radhika


Another Problem

my modal pop-up has yes or no options.When the user clicks on yes i have the onOkScript to a javascript function.

my Qs is how do i get the javascript to raise the event repeater_ItemCommand event of the repeater control.

Thanks!!

Radhika


Can you have the onOkScript code end by "clicking" (via .onclick()) a suitable element in the repeater control? I think people have had some success with this approach in the past.