Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
hello programmers, got a few errors here that I cannot solve myself.
Ive manage to add a pop up window on my master page so that I could call it everytime
XML
<script type="text/javascript">


        function OpenPopup() {
if (window.showModalDialog) {
    window.showModalDialog("PopUp.aspx", "PopUp",
"dialogWidth:550px;dialogHeight:300px");
} else {
window.open('PopUp.aspx', 'name', 'height=300,width=550,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes');
}
}
    </script>

See that I am calling PopUp,aspx
Now on my popup.aspx here is the trickest part
I am binding it with autocomplete extender with the source txtSearchBox
<form id="form1"  runat="server">
    <cc1:ToolkitScriptManager ID="ToolkitScriptManager1"  runat="server">
    </cc1:ToolkitScriptManager>

            <asp:Panel ID="Panel1" runat="server">
                <asp:Label ID="lblResult" runat="server" Visible="false" ForeColor="Red" Font-Bold="true"></asp:Label><br />
                <asp:Label ID="Label7" runat="server" Text="Search: " Width="100px"></asp:Label>
                <big><asp:TextBox ID="txtSearchBox"  OnTextChanged="txtSearchBox_TextChanged" AutoPostBack="true" Width="300px"
                    runat="server" Font-Names="verdana,arial,helvetica,sans-serif" Font-Size="XX-Small"></asp:TextBox></big>                <br />
                <br />
                <asp:Label ID="Label1" runat="server" Text="Course Code: " Width="100px"></asp:Label>
                <asp:TextBox ID="txtCourseCode" runat="server" Width="173px" Font-Names="verdana,arial,helvetica,sans-serif"
                    Font-Size="XX-Small"></asp:TextBox>
                <asp:CheckBox ID="checkMultiCode" AutoPostBack="true" Text="*multi codes" runat="server"
                    Font-Names="verdana,arial,helvetica,sans-serif" Font-Size="XX-Small" />
<%--                <div style="removed: absolute; removed 455px; removed 65px; width: 50px">
                    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UPanel">
                        <ProgressTemplate>
                            <img alt="Update in Progress" src="Images/load.gif" height="30px" />
                        </ProgressTemplate>
                    </asp:UpdateProgress>
                </div>--%>
                <br />
                <br />
                <asp:Label ID="Label2" runat="server" Text="Course Name: " Width="100px"></asp:Label>
                <asp:TextBox ID="txtCourseName" runat="server" Width="250px" Font-Names="verdana,arial,helvetica,sans-serif"
                    Font-Size="XX-Small"></asp:TextBox>
                <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtCourseName"
                    Font-Names="verdana" Font-Size="XX-Small" ErrorMessage="Needed"></asp:RequiredFieldValidator>--%>
                <br />
                <br />
                <asp:Label ID="Label3" runat="server" Text="Duration: " Width="100px"></asp:Label>
                <asp:TextBox ID="txtCourseDuration" runat="server" Width="250px" Font-Names="verdana,arial,helvetica,sans-serif"
                    Font-Size="XX-Small"></asp:TextBox>
                <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtCourseDuration"
                    Font-Names="verdana" Font-Size="XX-Small" ErrorMessage="Needed"></asp:RequiredFieldValidator>--%>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtCourseDuration"
                    Font-Names="verdana" Font-Size="XX-Small" ErrorMessage="Numbers/Decimal Only"
                    ValidationExpression="(^\d*\.?\d*[1-9]+\d*$)|(^[1-9]+\d*\.\d*$)"></asp:RegularExpressionValidator>
                <br />
                <br />
                <br />
<%--                <div style="display:none;">
                <asp:Button ID="button2" runat="server" HorizontalAlign="right" Width="200px"
                    Text="Update" align="right"/>
                    </div>--%>
                <asp:Button ID="ButtonUpdateCategory" runat="server" HorizontalAlign="right" Width="200px"
                    Text="Update" Visible="false" align="right" OnClientClick="CloseDialog()" />
                <asp:Button ID="ButtonSave" runat="server" HorizontalAlign="right" Width="200px"
                    Text="Save" align="right" />
                <asp:Button ID="btnCancel" runat="server" Width="200px" CausesValidation="false"
                    align="right" Text="Cancel" />
                <asp:Button ID="Button2" runat="server" align="right" Text="Cancel" Style="display: None" />
                <br />
                <br />
                <asp:TextBox ID="txtCourseCatID" Style="display: none" runat="server"></asp:TextBox>
                <asp:TextBox ID="txtCourseID" Style="display: none" runat="server"></asp:TextBox>
                <asp:TextBox ID="txtCode" Style="display: none" runat="server"></asp:TextBox>
                <div id="div1">
                    <cc1:AutoCompleteExtender ID="AutoCompleteExtender2"  runat="server" TargetControlID="txtSearchBox"
                        CompletionListCssClass="AutoExtenderCourse" CompletionListItemCssClass="AutoExtenderList"
                        CompletionListHighlightedItemCssClass="AutoExtenderHighlight" CompletionListElementID="div1"
                        CompletionSetCount="10" ServicePath="WebService.asmx" ServiceMethod="CourseCode"
                        CompletionInterval="10" MinimumPrefixLength="1">
                    </cc1:AutoCompleteExtender>
                </div>
            </asp:Panel>

    </form>

See that my txtSearchbox has ontextchange and auto postback. Now i can get the value i want but then it doesnt remain in the window popup thus it transfer the value to a new window.
VB
Protected Sub txtSearchBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSearchBox.TextChanged
        txtCourseName.text = txtSearchBox.text    End Sub
Posted

Use callback function. You can access parent window object in javascript by using window.parent or window.opener. You can pass the variables or access the control of child to parent or parent to child window.
Learn more about on the net.
 
Share this answer
 
Comments
janwel 31-Jan-12 0:02am    
im sorry sir but I am new to this modal window. coult you elaborate more sir?
got it i have to add target=_self on the head of the popUp.aspx
 
Share this answer
 

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