Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 27th, 2004, 01:06 AM
Authorized User
 
Join Date: Jul 2004
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aravwind Send a message via Yahoo to aravwind
Default problem in posting info frm child form to parent

web application
ASP.NET & VB.NET(code behind)


i got a parent form "parent.aspx"
have placed a button "Attachment" and a div "div1"
"onclick" i open the form "fload.aspx"
i got a "file control" and a list box.
the buttons are "add", "remove", and "attach"
i store the list of files in a hidden variable "txthd2".
when onclick "attach", i assign the values in the "txthd2" to the div
of the parent.aspx and close the fload.aspx window.
when i click the attach button in the fload.aspx file it is saying an error
line: 1
char: 48
error: Expected ';'
url: http://localhost/lf/fload.aspx



the code used for attach button is


Private Sub btnAt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAt.Click
        Dim i
        Dim arr As Array
        For i = 0 To ListBox1.Items.Count - 1
            arr = Split(ListBox1.Items(i).Value, "\")
            txthd2.Value = txthd2.Value & arr(arr.Length - 1) & ","
        Next

        Response.Write("<script language='javascript'>")
        Response.Write("function attach()")
        Response.Write("{")
        Response.Write("If (Form2.txthd2.value != '')")
        Response.Write("{")
        Response.Write("var parentFrm = window.parent.document.forms[0];")
        Response.Write("parentFrm.div1.innerHTML = Form2.txthd2.value;")
        Response.Write("window.close();")
        Response.Write("}")
        Response.Write("}")
        Response.Write("attach();")
        Response.Write("</script>")
    End Sub

i don't know why the error is coming









__________________
Aravindan.N
Faster and consistent will surely beat the slow and steady
 
Old July 27th, 2004, 12:44 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

First off: Thank you for provided the basic information about the application you are working on. (Obviously you read the forum description.)

I see a problem with your javascript:
"If" should by "if" (little i)
 
Old July 28th, 2004, 06:04 AM
Authorized User
 
Join Date: Jul 2004
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aravwind Send a message via Yahoo to aravwind
Default

ur saying is right
also i wore in the onclick event of the "btn_attach"
both client side script and serverside script.
as the clientside script is called first, there will be no
data stored in thwe hidden variable
so it was not functioning
now i changed the entire "btn_attach" click event to client side
it is working fine
and here is the code:

thank you

don't laugh at me planoe. i don't know to write in a single script so i written a part of script in vbscript and the rest in javascript and
called the vbscript in java script and put it in the <head> section. the problem is solved now.



<script language="vbscript">
public Function aa()
Dim i
Dim arr

For i = 0 To Form2.ListBox1.length - 1
   arr = Split(Form2.ListBox1.options(i).Value, "\")
Form2.txthd2.Value = Form2.txthd2.Value & arr(ubound(arr)) & ","
Next

Form2.txthd2.Value = Left(Form2.txthd2.Value,len(Form2.txthd2.Value) - 1)
End Function
</script>

<script language='javascript'>
<!--
function attach()
{
    if (Form2.ListBox1.options.length != 0)
    {
    aa();
    if (Form2.txthd2.value != "")
    {
    var parentFrm = window.opener.Form1;
                        //parentFrm.document.getElementById("div1").innerHTM L = Form2.txthd2.value;
if (parentFrm.document.getElementById("lbl1").innerHT ML != "")
{
parentFrm.document.getElementById("lbl1").innerHTM L = parentFrm.document.getElementById("lbl1").innerHTM L + "," + Form2.txthd2.value;
                    window.opener.document.getElementById("hdnAttachdo c").value = window.opener.document.getElementById("hdnAttachdo c").value + "," + Form2.txthd2.value;
}
else
{
                        //parentFrm.document.getElementById("lbl1").innerTex t = Form2.txthd2.value;
                        //alert(window.opener.document.getElementById("hdnAt tachdoc").value)
                        parentFrm.document.getElementById("lbl1").innerHTM L = Form2.txthd2.value;
                        window.opener.document.getElementById("hdnAttachdo c").value = Form2.txthd2.value;
                        //alert(window.opener.document.getElementById("hdnAt tachdoc").value)
                        }
window.close();
}
}
else
alert("Select a file from the list and attach")
}
-->
</script>













Similar Threads
Thread Thread Starter Forum Replies Last Post
Posting asp form variables from child to parent aspless Javascript How-To 0 July 20th, 2007 10:36 AM
Submitting a parent form from a child window in IE livehed Other Programming Languages 0 February 15th, 2007 01:07 PM
Reference to parent form from child prashantha Visual Basic 2005 Basics 2 November 15th, 2006 03:54 PM
parent form from child form - urgent plz netfresher C# 1 November 8th, 2006 06:59 PM
parent child form data passing maddy137 ASP.NET 1.0 and 1.1 Basics 0 April 26th, 2006 01:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.