a serious problem in adding value to a child form!!!!

V

Vadivel Kumar

Hi,

Iam facing a problem in adding a value to a list box which is located in
parent window thru a child window. I made the listbox as HTML control and
the following is the code i have written in the child window to add a value
in it.

When i clicked the submit button of child window it throws a error "Server
threws an exception" and the window is
get closed.

Plz help me!!.

function addOption(selectObject,optionText,optionValue) {
var optionObject = new Option(optionText,optionValue)
var optionRank = selectObject.options.length
selectObject.options[optionRank]=optionObject
}

</script>
<html>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form id="sellcateg" runat="server">
<INPUT id="btnsububmit"
onclick="addoption(window.opener.document.forms[0].ListBox1,'test','12');"
type="button" value="Submit" name="btnsubmit">
<asp:DataGrid id="MyDataGrid" runat="server" AutoGenerateColumns="false">
<columns>
<asp:BoundColumn DataField="cat_id" HeaderText="category
id"></asp:BoundColumn>
<asp:BoundColumn DataField="subcat_id" HeaderText="subcategory
id"></asp:BoundColumn>
<asp:BoundColumn DataField="subcategory"
HeaderText="subcategory"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="select">
<HeaderTemplate>
<Input type="checkbox" id="checkall" runat="server">
</headertemplate>
</asp:TemplateColumn>
</columns>
</asp:DataGrid>

Thanks in Advance
Vadivel Kumar
 
J

John Saunders

Vadivel Kumar said:
Hi,

Iam facing a problem in adding a value to a list box which is located in
parent window thru a child window. I made the listbox as HTML control and
the following is the code i have written in the child window to add a
value in it.

When i clicked the submit button of child window it throws a error "Server
threws an exception" and the window is
get closed.

First, please provide the complete text of the exception.

Second, please simplify this in order to create a small reproducer. For
instance, does the DataGrid have to be on the child form in order for you to
reproduce the problem?

John Saunders
 
V

Vadivel Kumar

No, let me explain again.

The parent window contains a listbox (HTML) and a button called "Add", once
the user clicks the Add button
a child window popups up with a datagrid contains a series of values and
checkbox and a single submit button, once
the user selects his required values thru checking checkboxes and clicks the
submit button the selected values
has to be added into the parent window's listbox.

I hope, this is clear as far as the functionality required here.

Now the problem, i'm facing is when ever the submit button get clicked iam
executing a javascript
which contains the (which i have pasted prev.) code to add values in the
parent window's listbox. I'm sure the javascript is called and when try to
alert the listbox name, it is working fine. Once i try to add the value it
throws an javascript error that
the "Server threws an exception". I don't find more clues about the error.

Parent window contains this code :-

<form id="r" runat="server">
<select id="r2">
<option value="default"> (No items selected) <option>
</select>
<input type="button" onclick="javascript:window.open('childwindow.aspx')"
value="Add">
</form>

Child window contains this code :-

<script language=javascript>

function addOption(selectObject,optionText,optionValue) {
var optionObject = new Option(optionText,optionValue)
var optionRank = selectObject.options.length
selectObject.options[optionRank]=optionObject
}

</script>

<form id="sellcateg" runat="server">
<INPUT id="btnsububmit"
onclick="addoption(window.opener.document.forms[0].r2,'test','12');"
type="button" value="Submit" name="btnsubmit">
<asp:DataGrid id="MyDataGrid" runat="server" AutoGenerateColumns="false">
<columns>
<asp:BoundColumn DataField="cat_id" HeaderText="category
id"></asp:BoundColumn>
<asp:BoundColumn DataField="subcat_id" HeaderText="subcategory
id"></asp:BoundColumn>
<asp:BoundColumn DataField="subcategory"
HeaderText="subcategory"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="select"><Input type="checkbox"
id="checkall" runat="server">
</asp:TemplateColumn>
</columns>
</asp:DataGrid>

I just re-constructed the code to suit with here.

Thanks in Advance
Vadivel Kumar

</form>
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top