Showing posts with label buttons. Show all posts
Showing posts with label buttons. Show all posts

Wednesday, March 21, 2012

need help with a modal extender control

I am working on a project that has two modal extenders on one page, and two panels. Which have their own separate buttons which can trigger each panel to open. On the same form there is a gridview control, the user will select a row then in the code behind i trigger the click event for one of the button, so that it will oepn one of the panel it seemed to work fine before just using modalextender...1.show() when it stop working i added the code to raisethe click event for the control. After doing so it doesn;t open the panel instead, i have to click the button that that is setup as theTargetControlID two or three time just for the pop up menu to open. What is the right way to go about doing this. I wander if anyone else has had the same problem.

((IPostBackEventHandler)lnkPanel2).RaisePostBackEvent(null);

this.ModalPopupExtender2.Show();

Hi Lew26,

My suggestion is use Javascript to show the ModalPopupExtender directly. For example:

use $find("ModalPopupExtender's BehaviorID ").show(); to show the Panel and use $find("ModalPopupExtender's BehaviorID ").hide(); to hide the showing Panel. The Buttons which will lead the ModalPopupExtender to shown or to hidden should be put inside a hidden div. Take an example: <div style="display:none">your Buttons</div>. Here is my sample:

<%@. Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<script runat="server"
protected void Page_Load(object sender, EventArgs e)
{
//Attach a Javascript funtion to the LinkButton.
LinkButton myLinkButton;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
myLinkButton = (LinkButton)GridView1.Rows[i].Cells[4].FindControl("LinkButton1");
myLinkButton.Attributes.Add("onclick", "shopModalPopup('" + GridView1.Rows[i].Cells[0].Text + "');return false;");
}
}
</script
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style>
.modalBackground {
background-color:Gray;
filter:alpha(opacity=70);
opacity:0.7;
}

.modalPopup {
background-color:#FFD9D5;
border-width:3px;
border-style:solid;
border-color:Gray;
padding:3px;
width:250px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="EmployeeID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID" InsertVisible="False"
ReadOnly="True" SortExpression="EmployeeID" ItemStyle-Width="0" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server">Click On Me</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NORTHWNDConnectionString%>"
SelectCommand="SELECT [EmployeeID], [LastName], [FirstName], [Title] FROM [Employees]">
</asp:SqlDataSource>
<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Height="200px" Width="300px" style="display:none">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
EmployeeID:<asp:TextBox ID="tbEmployeeID" runat="server"></asp:TextBox> <br/>
Reason:<asp:TextBox ID="tbReason" runat="server"></asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</asp:Panel>
<div style="display: none">
<asp:Button ID="Button1" runat="server" Text="Button" /></div>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Button1"
PopupControlID="Panel1" CancelControlID="btnCancel" BackgroundCssClass="modalBackground">
</ajaxToolkit:ModalPopupExtender>
<script type="text/javascript" language="javascript">
function shopModalPopup(employeeID){
//show the ModalPopupExtender
$get("<%=tbEmployeeID.ClientID%>").value = employeeID;
$get("<%=tbReason.ClientID%>").value ="";
$find("<%=ModalPopupExtender1.ClientID%>").show();
}
</script>
</form>
</body>
</html>

I hope this help.

Best regards,

Jonathan

Need help with hover menu on repeater rows..

Hi all! I am trying to use Hover Menu... on the rows generated by asp repeater.. and add EDIT and DELETE Link buttons in the menu... In on of the post in this forum I found that we need to initilize for every row.. I confused.. it wud be gr8 if any help me with some sample code...

<asp:Panel runat="server" ID="pnlcurroffer" GroupingText="<b>Current Offers Info</b>" Height="400px" Width="350" >
<asp:Button ID="btncurrprev" runat="server" CssClass="tbox" Text="<<" OnClick="currprev" />
<asp:Label ID="lblcurrpage" runat="server" />
<asp:Button ID="btncurrnxt" runat="server" CssClass="tbox" Text=">>" OnClick="currlnext" /
<table cellpadding="0" cellspacing="0" border="0" class="main" width="95%"
<tr>
<td colspan="4" class="top line"><img src="http://pics.10026.com/?src=~../images/spc.gif" height="2" width="1" alt="" /></td>
</tr>
<tr>
<td class="hed" style="height: 19px"><div class="mgn">ID</div></td>
<td class="hed" style="height: 19px"><div class="mgn">Name</div></td>
<td class="hed" style="height: 19px"><div class="mgn">PackInfo</div></td>
<td class="hed" style="height: 19px"><div class="mgn">Del</div></td>

</tr>
<tr>
<asp:Repeater ID="Repcurroffers" runat="server" OnItemDataBound="bindcurroffers" >
<ItemTemplate>
<tr class="white" onmouseover="this.className='high';" onmouseout="this.className='white';">
<td class="row"><div class="mgn"><%#Eval("spid")%></div></td>
<td class="row"><div class="mgn"><asp:Literal ID="lblcurroffname" runat="server" /></div></td>
<td class="row"><div class="mgn"><asp:Literal ID="lblcurrLead" runat="server" /></div></td>
<td class="row"><div class="mgn"><asp:LinkButton ID="lnkdel" runat="server" Text="Delete" CommandArgument='<%#Eval("Spid")%>' OnCommand="lnkDelOffer" /></div></td>
</tr>
</ItemTemplate>

</asp:Repeater>
</tr>
</table>
</asp:Panel>

Thanx guys

Hi,

Please change your code to:

<asp:Panel runat="server" ID="pnlcurroffer" GroupingText="<b>Current Offers Info</b>"
Height="400px" Width="350">
<asp:Button ID="btncurrprev" runat="server" CssClass="tbox" Text="<<" OnClick="currprev" />
<asp:Label ID="lblcurrpage" runat="server" />
<asp:Button ID="btncurrnxt" runat="server" CssClass="tbox" Text=">>" OnClick="currlnext" />
<table cellpadding="0" cellspacing="0" border="0" class="main" width="95%">
<tr>
<td colspan="4" class="top line">
<img src="http://pics.10026.com/?src=~../images/spc.gif" height="2" width="1" alt="" /></td>
</tr>
<tr>
<td class="hed" style="height: 19px">
<div class="mgn">
ID</div>
</td>
<td class="hed" style="height: 19px">
<div class="mgn">
Name</div>
</td>
<td class="hed" style="height: 19px">
<div class="mgn">
PackInfo</div>
</td>
<td class="hed" style="height: 19px">
<div class="mgn">
Del</div>
</td>
</tr>
<asp:Repeater ID="Repcurroffers" runat="server" OnItemDataBound="bindcurroffers">
<ItemTemplate>
<tr>
<td colspan="4">
<asp:Panel ID="Panel1" runat="server">

<table>
<tr class="white" onmouseover="this.className='high';" onmouseout="this.className='white';">
<td class="row">
<div class="mgn">
<%#Eval("spid")%>
</div>
</td>
<td class="row">
<div class="mgn">
<asp:Literal ID="lblcurroffname" runat="server" /></div>
</td>
<td class="row">
<div class="mgn">
<asp:Literal ID="lblcurrLead" runat="server" /></div>
</td>
<td class="row">
<div class="mgn">
<asp:LinkButton ID="lnkdel" runat="server" Text="Delete" CommandArgument='<%#Eval("Spid")%>'
OnCommand="lnkDelOffer" /></div>
</td>
</tr>
</table>
</asp:Panel>
<ajaxToolkit:HoverMenuExtender ID="hme1" runat="Server" TargetControlID="Panel1"
PopupControlID="PopupMenu" HoverCssClass="popupHover" PopupPosition="Right" />
<asp:Panel ID="PopupMenu" runat="server" CssClass="popupMenu">
<div style="border: 1px outset white">
<asp:LinkButton ID="LinkButton1" runat="server" />
<br />
<asp:LinkButton ID="LinkButton2" runat="server" />
</div>
</asp:Panel>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>

</table>
</asp:Panel>

Best Regards,


Thank you so much!!!

Need Help with Modal Popup!

Here's the deal...

I have a bound DetailsView (user control) that I have created custom command buttons for (add, edit, save, cancel).

Upon edit, I am storing the values for each field to hidden textboxes on the form. Upon save, I will need to run custom validation routine(s), as well as, compare old vs. new values (some changes will trigger back-end processes to kick off via SQL triggers and we want alert the user of this up front).

Once validation passes, if one or more of the values have changed that will cause execution of the triggers, I want to manually launch a popup [ modalpopup1.show() ] that lists the specific changes and asks the user to Confirm (ie., "Are they sure they want to Save?"). If so, the app will proceed with updating / saving the record and the SQL proc will go ahead and execute. If not, the update is cancelled and the detailsview goes back into read only mode.

Problem I am having is that the Modal wants me to specify a "TargetControlId" and I am not sure what that control should be. I tried making it the Save button, but doing so will cause the modal to appear immediately (ie., before the validations and old vs. new compare routine) executes. So I then tried creating a dummy button, but get the following error message: "The control 'btn_Dummy' already has a data item registered. Parameter name: control".

Can anyone help me on the proper way to code / implement this ?

Hi ,

The "TargetControlId" specifies the Control which will trigger the ModalPopup to Show .

What you can do is .. Once you come to know that certain changes have been made to the data , you can use the Client side methods of the ModalPopup to Show / Hide

Show and Hide ModalPopupExtender from JavaScript

Let me know if I missed anything


I tried this via example provided via thread ("Show Popup Dynamically via js") , but I really would like to popup the modal from another button's code behind (ie., after all my validations checks have been completed). Is there not a way to do this?

If not, I guess the only alternative would be to re-write the validation routines in js and call the popup from there??


From ServerSide , you have access to the ModalPopup's Show method using

ModalPopupExtender1.Show()

From Client side , use the method described in my previous reply.


Hi,

Still getting error message "data item already registered" when attempting to use ModalPopupExtender1.show().

Found thishttp://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=7115 after doing more research on Google. It appears to be a bug.

Appreciate your trying to help. I've decide to manually hide / unhide my panels instead of the AJAX control until the above is resolved.

Thanks,

Annette