473,796 Members | 2,595 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 1324

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

Similar topics

3
10571
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
2503
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
3119
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
6055
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
4893
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
3883
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
9679
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
9527
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10453
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10172
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
10003
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...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
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
6785
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();...
1
4115
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

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.