Click here to Skip to main content
16,011,744 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Controls in the Home page: TextBox, Button
Controls in Pop up: Gridview

What I want to achieve and used so far:
1. Enter text in the textbox and click on the button.
C#
protected void btnLookUp_Click(object sender, EventArgs e)
{
    string sScript = "<script>window.open('a.aspx?textbox=" + TextBox1.Text.ToString() + "','cal','left=10,top=10 resizable= yes scrollbars=yes') </script>";
    RegisterClientScriptBlock("anything", sScript);
}


2. On Button-Click the pop-up opens and on-page load event of the popup page gets triggered.
Gridview control in pop-up page.
XML
<asp:GridView ID="GridView1" runat="server" Font-Size="10px"
    onselectedindexchanged="GridView1_SelectedIndexChanged">
    <Columns>
        <asp:CommandField SelectText="[...]" ShowSelectButton="True" />
    </Columns>
    <AlternatingRowStyle Wrap="False" />
</asp:GridView>


3. On clicking the button for the corresponding entry in the gridview I want to pass selected column values back to the TextBox control in the home page.
C#
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
    string strScript = "<script>window.opener.document.forms(0)."+ control.Value.ToString() +".value = '";
    //strScript += GridView1.SelectedIndex.ToString();
    strScript += "Amresh';self.close()";
    strScript += "</" + "script>";
    RegisterClientScriptBlock("anything", strScript);
}

The above code gives me error '; missing' as the the column values starts with an integer value.

How do I transfer values back to the textbox in the home from the popup page?
Or can I achieve it using some other method?
Posted
Updated 15-May-11 21:54pm
v3
Comments
Dalek Dave 16-May-11 3:54am    
Edited for Grammar and Readability.

The error is very descriptive. You are missing ; on the following line

strScript += "Amresh';self.close()";
 
Share this answer
 
Comments
lionelcyril 16-May-11 2:19am    
I had tht tried initially .. i had tht removed while debugging.
The error seems to be in the following line:
control.Value.ToString() +".value = '";
as the colum value starts with a number.
 
Share this answer
 
Comments
Dalek Dave 16-May-11 3:55am    
Useful link.
Try Break the line in code after comma only

protected void btnLookUp_Click(object sender, EventArgs e)
{
    string sScript = "<script>window.open('a.aspx?textbox=" + TextBox1.Text.ToString() + "','cal',
'left=10,top=10 resizable= yes scrollbars=yes') </script>";
    RegisterClientScriptBlock("anything", sScript);
}


Hope it works
 
Share this answer
 
v2
Comments
lionelcyril 16-May-11 2:31am    
break in line???
It'll throw ';' missing error..
Try that way

string strScript = "<script>window.opener.document.getElementByID('" + control.Value.ToString() + "').value = 'Amresh';self.close();</script>";
 
Share this answer
 
Comments
lionelcyril 16-May-11 2:50am    
Error :
Object doesnt suppor this property or method.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900