Advertisement

06.30.2008 at 05:14AM PDT, ID: 23526578
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

Open/Close Window vai JavaScript in C#

Asked by attaylor44 in JavaScript, C# Programming Language

Tags:

I have a form, this form has a text box for searching and a button to search.  
On button click, a new window is opened with a gridview control that populates based on the search criteria entered in the main page. This grid view has buttonfield elements that allow the user to open form documents (insurance application) pre-populated with previously entered data.  

What happens on the click event of one of these buttonfields is I call a javascript function that calls the codebehind first to set sesson variables(not using query strings at all, so all insurance application ID information is set to a session variable).  Once the session variables are set, the page redirects to the specific url of the particular referenced applcation/form.

My problem is:  I have opened an insurance application for Client "A", I then minimize this window and am back to my main window, I perform another search, a new window is populated and I open an application for Client "B", the session variables are overwritten so that Client "B's" information is now available.  If I return to Client "A's" window and hit a save button, it overwrites client "B's" information in the database as it updates based on the session variable of an application ID.  

I need to ensure that if a new client's application is opened, the previous one is closed so that it cannot overwirte the wrong client's information.  I am attaching some code, but I think the concept is the bigger picture, I may even be going about this in the wrong direction, any other suggestions would be of great help as well.  Sometimes the straight forward answer isn't the best one!

I would be pleased if the click of the search button closed any previous instance of an open window before opening a new window.... this would insure that no other client applcation/forms are open (we do not need to allow the end user to view multiple accounts at a single time).

For the most part, I just want a button click event that checks to see if a window of name "my_window" has been opened, if it has been opened, I want the code to close it before opening it again with the new information.  If it is not currently open, I want to simply open a new instance of "my_window".  

With this idea, I can have a search field and button on FormA, the user clicks the button to search, it checks to see if a window is open (not just any window, but the window with a name, a child window... something like that) and if it is, close it to ensure that the user will NOT write over existing informaiton, set session variables to reference new documentID, and open a new window.

More or less, I need to know how to have a C# page open a window that it can mantain a reference to so that the button that generates this new page can check/colse the window it created.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
Main Page:
 
//search section
<tr>
                <td>
                <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
                </td>
                <td>
                    <asp:Button ID="btnSearch" runat="server" Text="Search By FirmName" OnClientClick="Search()" OnClick="btnSearch_Click"  /></td>
            </tr>
 
 
JavaScript on main page:
function Search()
{
    
    <%=Page.GetPostBackEventReference(btnSearch as Control) %>
    
    window.open('/Pages/FirmSearch.aspx');
    
}
 
=====================================================
 
Codebehind for search button on aspx.cs page
protected void btnSearch_Click(object sender, EventArgs e)
        {
            Session["SearchText"] = null;
 
            Session["SearchText"] = txtSearch.Text.ToString() + "%";
            Session["searchText"].ToString();
        }
 
======================================================
 
 
Window with gridview:
 
<asp:GridView ID="gvFirmSearch" runat="server" AllowPaging="True" AutoGenerateColumns="False"
        CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None"
        Width="530px" OnSelectedIndexChanged="gvFirmSearch_SelectedIndexChanged" OnRowCommand="gvFirmSearch_RowCommand">
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <RowStyle BackColor="#EFF3FB" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#2461BF" />
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:ButtonField DataTextField="firmname" HeaderText="Firm Name"  CommandName="OpenFirm" />
            <asp:BoundField DataField="email" HeaderText="email" SortExpression="email" />
            <asp:BoundField DataField="password" HeaderText="password" SortExpression="password" />
            <asp:ButtonField CommandName="OpenPIR" Text="Premium Indication" />
            <asp:ButtonField CommandName="OpenNewApp" Text="New App" />
        </Columns>
    </asp:GridView>
 
=======================================
codebehind for gridview click:
 
protected void gvFirmSearch_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string userid = gvFirmSearch.Rows[int.Parse(e.CommandArgument.ToString())].Cells[1].Text.ToString();
 
            e.CommandName.ToString();
            
 
            DataAccess.getClientIDByEmail(userid.ToString());
            DataAccess.getAppIDByClientID(Session["clientid"].ToString());
            Session["SignedIn"] = "1";
            
            if(e.CommandName.ToString() == "OpenPIR")
                Response.Redirect("/pages/PremiumIndication/PremiumIndication.aspx",false);
            else
	            if(e.CommandName.ToString() == "OpenNewApp")
                    Response.Redirect("/pages/NewApp/NewApp.aspx", false);
                else
                    if (e.CommandName.ToString() == "OpenFirm")
                        Response.Redirect("/pages/UserArea.aspx", false);
            
        }
[+][-]06.30.2008 at 06:49AM PDT, ID: 21899086

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: JavaScript, C# Programming Language
Tags: JavaScript in C# Page
Sign Up Now!
Solution Provided By: Airyck666
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628