473,324 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

ajax, modalpopupextender/updatepanel

Hi,

I have a listbox (lstItems) that I want to populate with the items in
another listbox (lstSelected) that's in a modalpopupextender. 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
modalpopupextender.
Anyone know how to slove this?

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

<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>Untitled Page</title>

<style type="text/css">

..modalBackground {

background-color:Gray;

filter:alpha(opacity=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:ToolkitScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel2" runat="server">

<ContentTemplate>

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

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTrigger ControlID="lnkBtnOk" EventName="Click" />

</Triggers>

</asp:UpdatePanel>
<asp:LinkButton ID="lnkEdit" runat="server">Edit</asp:LinkButton>
<ajaxToolkit:ModalPopupExtender

ID="ModalPopupExtender1"

runat="server"

DropShadow="true"

PopupControlID="pnlEdit"

TargetControlID="lnkEdit"

BackgroundCssClass="modalBackground"

OkControlID="lnkBtnOk"

CancelControlID="lnkBtnCancel" />

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

<asp:LinkButton ID="lnkBtnOk" runat="server" Text="close"
OnClick="lnkBtnOk_Click"></asp:LinkButton>

<asp:LinkButton ID="lnkBtnCancel" runat="server" Text="close"
style="display:none;"></asp:LinkButton>

</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">

<ContentTemplate>

<div style="float: left;">

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

</div>

<div style="float: left;">

<asp:Button ID="btnAdd" runat="server" Text=" " ToolTip="Add"
CausesValidation="false" OnClick="btnAdd_Click" /><br />

<asp:Button ID="btnDel" runat="server" Text=" < " ToolTip="Remove"
CausesValidation="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(object sender, EventArgs e)

{

ScriptManager1.RegisterAsyncPostBackControl(lnkBtn Ok);

if (!Page.IsPostBack)

{

lstAvailable.Items.Add("a");

lstAvailable.Items.Add("b");

lstAvailable.Items.Add("c");

lstAvailable.Items.Add("d");

lstAvailable.Items.Add("e");

lstAvailable.Items.Add("f");

}

}

protected void btnAdd_Click(object sender, EventArgs e)

{

if (lstAvailable.SelectedIndex -1)

{

string value = lstAvailable.SelectedItem.Value;

RemoveItem(lstAvailable, value);

AddItem(lstSelected, value);

//AddItem(lstItems, value);

}

}

protected void btnDel_Click(object sender, EventArgs e)

{

if (lstSelected.SelectedIndex -1)

{

string value = lstSelected.SelectedItem.Value;

RemoveItem(lstSelected, value);

//RemoveItem(lstItems, value);

AddItem(lstAvailable, value);

}

}

protected void lnkBtnOk_Click(object sender, EventArgs e)

{

lstItems.Items.Clear();

foreach(ListItem li in lstSelected.Items)

lstItems.Items.Add(li.Value);

UpdatePanel2.Update();

}

private void RemoveItem(ListBox lst, string value)

{

ListItem o = lst.Items.FindByValue(value);

if (lst.Items.Count 1)

{

if (lst.SelectedIndex == lst.Items.Count - 1)

lst.SelectedIndex--;

else

lst.SelectedIndex++;

}

else

lst.SelectedIndex = -1;

lst.Items.Remove(o);

}

private void AddItem(ListBox lst, string value)

{

lst.SelectedIndex = -1;

lst.Items.Add(value);

lst.SelectedIndex = lst.Items.IndexOf(lst.Items.FindByValue(value));

}
Jun 27 '08 #1
0 1269

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

Similar topics

3
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...
1
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...
0
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...
3
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...
1
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...
0
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,”...
4
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...
3
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...
3
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.