Keep the value in the listbox after postback.

T

Ted Ngo

Hi All,
I am trying to pass the text and value from the listbox of my child
window to my listbox of parent window (this listbox is in gridview
control - Multiple listbox in this control). I were able to that, but
when I click on other button to make the popup window come up (in the
same gridview) then the value in the previous listbox (parent window)
goes away, if I don't refresh my parent page then the value is still
there. Some one suggests using hidden filed but I am not sure how,
please help Below is the code in my parent window and child page:

Parent:

<script language="JavaScript" type="text/JavaScript">
function NewOption(CtrlID, TxtValue, ValueID)
{
var objsel = document.getElementById(CtrlID);
var lobjOption = document.createElement("OPTION");
lobjOption.value = ValueID;
lobjOption.text = TxtValue;
objsel.options.add(lobjOption);
}

function MyPopUpWindow()
{
window.open(mypage,myname,settings);
lovwin.focus();
}

<asp:GridView>
<asp:TemplateField>
<ItemTemplate>
<asp:ListBox runat=server id=lstdata Width=225px Rows=1>
</asp:ListBox>
&nbsp;
<asp:ImageButton ImageUrl="~/images/selection.gif"
runat=server ID=btnlov OnClientClick=" MyPopUpWindow();" />
</ItemTemplate>
</asp:TemplateField>
</asp:GridView>

PopupWindow:
function PostBackData()
{
var source=document.getElementById("listboxdata");
var controlID = '<%=txtboxID %>'
var maxItems = source.options.length;

for (i=0;i<maxItems;i++)
{
if (source.options.selected==true)
{
window.opener.NewOption(controlID, source.options.text,
source.options.value);
}
}

window.opener.focus();
window.close();

}

Please help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top