473,804 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ajax, modalpopupexten der/updatepanel

Hi,

I have a listbox (lstItems) that I want to populate with the items in
another listbox (lstSelected) that's in a modalpopupexten der. The update is
supposed to happen when I close the modalpopup so I tried to add a trigger
for the click event of the ok button but it seems this event is not fired
anymore on serverside when it's used as the OnOkControlID for the
modalpopupexten der.
Anyone know how to slove this?

Best regards.
-----webform-----

<%@ Page Language="C#" AutoEventWireup ="true" EnableEventVali dation="true"
CodeFile="Defau lt.aspx.cs" Inherits="_Defa ult" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title>Untitl ed Page</title>

<style type="text/css">

..modalBackgrou nd {

background-color:Gray;

filter:alpha(op acity=70);

opacity:0.7;

}
..modalPopup {

/*background-color:#ffffdd;*/

background-color: #ffffff;

border-width:3px;

border-style:solid;

/*border-color:Gray;*/

border-color: #0079b9;

padding: 3px 3px 30px 3px;

width: 670px;

height: 110px;

}

</style>


</head>

<body>

<form id="form1" runat="server">

<ajaxToolkit:To olkitScriptMana ger ID="ScriptManag er1" runat="server" />
<asp:UpdatePane l ID="UpdatePanel 2" runat="server">

<ContentTemplat e>

<asp:ListBox ID="lstItems" runat="server"> </asp:ListBox>

</ContentTemplate >

<Triggers>

<asp:AsyncPostB ackTrigger ControlID="lnkB tnOk" EventName="Clic k" />

</Triggers>

</asp:UpdatePanel >
<asp:LinkButt on ID="lnkEdit" runat="server"> Edit</asp:LinkButton>
<ajaxToolkit:Mo dalPopupExtende r

ID="ModalPopupE xtender1"

runat="server"

DropShadow="tru e"

PopupControlID= "pnlEdit"

TargetControlID ="lnkEdit"

BackgroundCssCl ass="modalBackg round"

OkControlID="ln kBtnOk"

CancelControlID ="lnkBtnCanc el" />

<asp:Panel ID="pnlEdit" runat="server" CssClass="modal Popup"
style="display: none;">
<div id="pnlHeader" style="text-align: right;">

<asp:LinkButt on ID="lnkBtnOk" runat="server" Text="close"
OnClick="lnkBtn Ok_Click"></asp:LinkButton>

<asp:LinkButt on ID="lnkBtnCance l" runat="server" Text="close"
style="display: none;"></asp:LinkButton>

</div>
<asp:UpdatePane l ID="UpdatePanel 1" runat="server" UpdateMode="Alw ays">

<ContentTemplat e>

<div style="float: left;">

<asp:ListBox ID="lstAvailabl e" runat="server"> </asp:ListBox>

</div>

<div style="float: left;">

<asp:Button ID="btnAdd" runat="server" Text=" " ToolTip="Add"
CausesValidatio n="false" OnClick="btnAdd _Click" /><br />

<asp:Button ID="btnDel" runat="server" Text=" < " ToolTip="Remove "
CausesValidatio n="false" OnClick="btnDel _Click" />

</div>

<div style="float: left;">

<asp:ListBox ID="lstSelected " runat="server"> </asp:ListBox>

</div>

</ContentTemplate >

</asp:UpdatePanel >
</asp:Panel>
</form>

</body>

</html>

-----Code behind-----

protected void Page_Load(objec t sender, EventArgs e)

{

ScriptManager1. RegisterAsyncPo stBackControl(l nkBtnOk);

if (!Page.IsPostBa ck)

{

lstAvailable.It ems.Add("a");

lstAvailable.It ems.Add("b");

lstAvailable.It ems.Add("c");

lstAvailable.It ems.Add("d");

lstAvailable.It ems.Add("e");

lstAvailable.It ems.Add("f");

}

}

protected void btnAdd_Click(ob ject sender, EventArgs e)

{

if (lstAvailable.S electedIndex -1)

{

string value = lstAvailable.Se lectedItem.Valu e;

RemoveItem(lstA vailable, value);

AddItem(lstSele cted, value);

//AddItem(lstItem s, value);

}

}

protected void btnDel_Click(ob ject sender, EventArgs e)

{

if (lstSelected.Se lectedIndex -1)

{

string value = lstSelected.Sel ectedItem.Value ;

RemoveItem(lstS elected, value);

//RemoveItem(lstI tems, value);

AddItem(lstAvai lable, value);

}

}

protected void lnkBtnOk_Click( object sender, EventArgs e)

{

lstItems.Items. Clear();

foreach(ListIte m li in lstSelected.Ite ms)

lstItems.Items. Add(li.Value);

UpdatePanel2.Up date();

}

private void RemoveItem(List Box lst, string value)

{

ListItem o = lst.Items.FindB yValue(value);

if (lst.Items.Coun t 1)

{

if (lst.SelectedIn dex == lst.Items.Count - 1)

lst.SelectedInd ex--;

else

lst.SelectedInd ex++;

}

else

lst.SelectedInd ex = -1;

lst.Items.Remov e(o);

}

private void AddItem(ListBox lst, string value)

{

lst.SelectedInd ex = -1;

lst.Items.Add(v alue);

lst.SelectedInd ex = lst.Items.Index Of(lst.Items.Fi ndByValue(value ));

}
Jun 27 '08 #1
0 1326

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
10574
by: Not Me | last post by:
Hey, I'm using the MS AJAX libraries to achieve a modal popup window. Prior to using the toolkit control, I have a gridview and detailsview objects visible on the page.. when the gridview row is selected, the detailsview updates (in a seperate updatepanel - no full refresh) Now I've added the modalpopupextender and the result is that although the ok/cancel buttons on the panel appear.. the details within the detailview are blank...
1
4730
by: Victor | last post by:
Hi guys i have a strange problem about my modalpopupextender. In my page, i put a gridview inside a updatepanel with paging enabled. also i put a modalpopupextender in another updatepanel to do the edit and add new job. My problem is everytime time i change the page index in my gridview. and i click my add new button the validator in the modalpopupextender will show the error message. but after i click the cancel button to close the...
0
3957
by: SD | last post by:
Hi, I have to use the ModalPopupExtender prgrammatically.. But the next sample doesn't work: ************************** protected Button bt; protected Button bc; protected Button b; protected Panel p; protected Label lb; protected UpdatePanel up;
3
2504
by: =?Utf-8?B?UnlhbiBTbWl0aA==?= | last post by:
I have a form that has a ModalPopupExtender on it. I have un updatepanel on a panel control that is displayed when an Button (outside of the update panel) is clicked. What I am trying to do is fire the updatepanel with a command like "show_first" so that I can display appropriate informaiton in the updatepanel when the Button is clicked. I need to access the Button's click event Server Side so i can show the appropriate information. I...
1
4855
by: mbruyns | last post by:
i have been trying (and sometimes succeeding) to use the modalpopupextender to show various panels of controls on my asp pages. the strange problem that i keep on running into is that sometimes it works, displaying an awesome popup, while other times, it doesn't show a popup at all, but rather just page posts back and the panel becomes visible at the bottom of the page (where it is situated in the designer). what is even stranger to me is that...
0
3121
by: vincent90152900 | last post by:
In a web page,” Default.aspx”, I have two different WebUserControl,” WebUserControl1_1”, and “WebUserControl2_1” and a ModalPopupExtender,” ModalPopupExtender1” and a Button,” Button1” and a Panel,” Panel1”. When I click the Button1, the Panel1 will pop up. WebUserControl1_1 and WebUserControl2_1 both have a LinkButton,” LinkButton1”. I wish when user click the LinkButton1 in the WebUserControl1_1 and WebUserControl2_1, the Panel1 in the...
4
6056
by: pablorp80 | last post by:
Hello, Here is what I need: I need the focus and the cursor set to a textbox named txtGT, every time no matter if it is the first page load or whether it is a postback. Here is the problem: I am using AJAX and MasterPages as well as an update panel, the textbox is in a panel. I have tried to do it using different java scripts but I can't get it to work because I am not using asp forms, instead I am using Containers. Here is my code:...
3
4895
by: pechar | last post by:
Hi all, First of all I've searched the net but with no luck. My problem is I have a master/detail webform. i.e. the user clicks a record from the list and I show a modalpopup with the data. Here the user can edit this data. Apart from clientside validation I have some server validation (which I need). In the (server) Click event of the submit LinkButton I have the following: protected void lbtnSave_Click(object sender, EventArgs e) ...
3
3886
by: Mike Hofer | last post by:
Okay, here's the situation: we want to be able to display ASPX pages in an UpdatePanel. The reasons for this are performance related. The site in development uses *lots* of modal popups from some pages, and we don't want to load all that content until it's requested. So, what we want to do is place an IFRAME inside an UpdatePanel and, in the onclick event for the linkbutton or button control, set the SRC so that the content is loaded on...
0
9712
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10089
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5530
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.