Live Chat Icon For mobile
Live Chat Icon

How to select a value from a child form and send it to parent form

Platform: ASP.NET| Category: Miscellaneous


<asp:TextBox id='txtSelect' style='Z-INDEX: 101; LEFT: 186px; POSITION: absolute; TOP: 19px'
<a href='javascript:my_window =’page2.aspx?formname=Form1.txtSelect’ , ’my_window’,’width=300,height=300’); my_window.focus()'>
	Select CategoryName</a>


<asp:DropDownList id='DropDownList1' style='Z-INDEX: 101; LEFT: 180px; POSITION: absolute; TOP: 66px'
	runat='server' AutoPostBack='True'>
<asp:Label id='Label1' style='Z-INDEX: 102; LEFT: 16px; POSITION: absolute; TOP: 66px' runat='server'>Select Category  Name
<asp:Literal id='Literal1' runat='server'>


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
	’Put user code to initialize the page here
	If Not Page.IsPostBack Then
		’Fill DataSet ....	
	            DropDownList1.DataSource = ds.Tables(0)
	            DropDownList1.DataTextField = 'CategoryName'
	            DropDownList1.DataValueField = 'CategoryId'
	End If
End Sub

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
	            Dim strjscript As String = '<script language=''javascript''>'
	            strjscript = strjscript & 'window.opener.' & HttpContext.Current.Request.QueryString('formname') & '.value = ’' & DropDownList1.SelectedItem.Text & '’;window.close();'
	            strjscript = strjscript & '</script>'
	            Literal1.Text = strjscript
	Catch ex As Exception
	End Try
End Sub


private void Page_Load(object sender, System.EventArgs e)
	// Put user code to initialize the page here
	if (!Page.IsPostBack )
	            //Fill DataSet
                            DropDownList1.DataSource = ds.Tables[0];
	            DropDownList1.DataTextField = 'CategoryName';
	            DropDownList1.DataValueField = 'CategoryId';

private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
	            string strjscript  = @'<script language=''javascript''>';
	            strjscript = strjscript + 'window.opener.' + HttpContext.Current.Request.QueryString['formname'].ToString () + '.value = ’' + DropDownList1.SelectedItem.Text + '’;window.close();';
	            strjscript = strjscript + '</script>';
	            Literal1.Text = strjscript;
	catch(Exception ex)
	           Response.Write (ex.Message );

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.