Help with C# using popup pox

Discussion in 'ASP .Net' started by Artunc, Jun 30, 2009.

  1. Artunc

    Artunc Guest

    Hi,
    I have a form that people enter their 9 digit account numbers and hit submit
    to email them to me. They have option of up to 4 different account numbers to
    enter, (4 text boxes). When they hit submit, it opens a new popup window
    that says congratulations.

    What I need to accomplish is to calculate how many account numbers they
    entered (1,2,3, or 4) and put that into that popup. So it would say 'thank
    you for entering X number of accounts'. Belows is how I do the popup.

    In server side .cs page:
    string url = "cwbpopup.html";
    RegisterStartupScript("OpenWin", "<script>openNewWin('" + url +
    "')</script>");

    In client side .aspx page:
    <asp:button id="btnSubmit" runat="server" Text="Submit"
    onclick="btnSubmit_Click" CssClass="button" tabIndex="19"></asp:button>

    Thank you in advance.
    Artunc, Jun 30, 2009
    #1
    1. Advertising

  2. Artunc

    Artunc Guest

    Thanks Mark, I will take a look at you suggestions.

    What I'm trying to figure out is how to determine how many entered on the
    server side, and then pass that number to a sub-page or popup.




    "Mark Rae [MVP]" wrote:

    > "Artunc" <> wrote in message
    > news:...
    >
    > > I have a form that people enter their 9 digit account numbers and hit
    > > submit
    > > to email them to me. They have option of up to 4 different account numbers
    > > to
    > > enter, (4 text boxes). When they hit submit, it opens a new popup window
    > > that says congratulations.

    >
    > I would strongly advise you NOT to pop up new windows, especially in public
    > web sites.
    >
    > Instead, I would suggest that you use this:
    > http://www.asp.net/ajax/ajaxcontroltoolkit/samples/modalpopup/modalpopup.aspx
    >
    >
    > > RegisterStartupScript("OpenWin", "<script>openNewWin('" + url +
    > > "')</script>");

    >
    > If you absolutely must do the above, then I would suggest that you use the
    > boolean overload which will inject the correct standards-compliant <script>
    > tags automatically depending on the DOCTYPE you're using, e.g.
    >
    > RegisterStartupScript(GetType(), "OpenWin", "openNewWin(" + url + ");"),
    > true);
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    >
    >
    Artunc, Jun 30, 2009
    #2
    1. Advertising

  3. Artunc

    Artunc Guest

    I have the below code for each of 4 account boxes. How to count each box
    that has some numbers entered is my question. :)

    <td class="formHeader" align="right"><P align="left">Account Number
    1:</P></td>
    <td><asp:textbox id="Accntbox1" runat="server" class="text" tabIndex="12"
    MaxLength="25"></asp:textbox></td>


    "Mark Rae [MVP]" wrote:

    > "Artunc" <> wrote in message
    > news:...
    >
    > > I have a form that people enter their 9 digit account numbers and hit
    > > submit
    > > to email them to me. They have option of up to 4 different account numbers
    > > to
    > > enter, (4 text boxes). When they hit submit, it opens a new popup window
    > > that says congratulations.

    >
    > I would strongly advise you NOT to pop up new windows, especially in public
    > web sites.
    >
    > Instead, I would suggest that you use this:
    > http://www.asp.net/ajax/ajaxcontroltoolkit/samples/modalpopup/modalpopup.aspx
    >
    >
    > > RegisterStartupScript("OpenWin", "<script>openNewWin('" + url +
    > > "')</script>");

    >
    > If you absolutely must do the above, then I would suggest that you use the
    > boolean overload which will inject the correct standards-compliant <script>
    > tags automatically depending on the DOCTYPE you're using, e.g.
    >
    > RegisterStartupScript(GetType(), "OpenWin", "openNewWin(" + url + ");"),
    > true);
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    >
    >
    Artunc, Jun 30, 2009
    #3
  4. Artunc

    Artunc Guest

    "Mark Rae [MVP]" wrote:

    > "Artunc" <> wrote in message
    > news:...
    >
    > [please don't top-post]
    > http://www.caliburn.nl/topposting.html
    >
    > > I have the below code for each of 4 account boxes. How to count each box
    > > that has some numbers entered is my question. :)
    > >
    > > <td class="formHeader" align="right"><P align="left">Account Number
    > > 1:</P></td>
    > > <td><asp:textbox id="Accntbox1" runat="server" class="text" tabIndex="12"
    > > MaxLength="25"></asp:textbox></td>

    >
    > Client-side:
    > document.getElementById('<%=Accntbox1%>').value.length;
    >
    > Server-side:
    > Accntbox1.Text.Length;
    >


    I'm not sure this is what I'm trying to do. Correct me if I'm wrong, your
    code counts the digits in the account box.

    What I need is to count each box that has value in it as one and come up
    with a total number in the end. If 3 account numbers in box 1,2 and 3, then
    the value would be 2.

    I'm thinking of something like below but I don't know how to count each one
    and get a total in the end.

    String.IsNullOrEmpty(Accntbox1.Text)
    Artunc, Jun 30, 2009
    #4
  5. Artunc

    Artunc Guest

    Thank you very much, I will try this and post the results here.

    "Mark Rae [MVP]" wrote:

    > "Artunc" <> wrote in message
    > news:...
    >
    > > I'm not sure this is what I'm trying to do. Correct me if I'm wrong, your
    > > code counts the digits in the account box.

    >
    > That's right - and if the answer is greater than zero, then you know that
    > textbox has a value in it...
    >
    > > I'm thinking of something like below but I don't know how to count each
    > > one
    > > and get a total in the end.

    >
    > byte bytBoxCount = 0;
    >
    > if (Accntbox1.Text.Length > 0) { bytBoxCount++; }
    > if (Accntbox2.Text.Length > 0) { bytBoxCount++; }
    > if (Accntbox3.Text.Length > 0) { bytBoxCount++; }
    > if (Accntbox4.Text.Length > 0) { bytBoxCount++; }
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    >
    >
    Artunc, Jun 30, 2009
    #5
  6. Artunc

    Artunc Guest

    I can't get the number to show up in the popup.html page.
    Ok here's what I have so far. Please let me know if I'm on the right track.

    In the main form page:

    <script>
    function openNewWin(url)
    {
    var x = window.open('popup1.html', 'mynewwin',
    'width=725,height=380',Toolbar=1);
    x.focus();
    }
    </script>

    In the .cs file:

    byte bytBoxCount = 0;
    if (txtTextbox2.Text.Length > 0) { bytBoxCount++; }
    if (txtTextbox4.Text.Length > 0) { bytBoxCount++; }
    if (txtTextbox6.Text.Length > 0) { bytBoxCount++; }
    if (txtTextbox8.Text.Length > 0) { bytBoxCount++; }
    string url = "popup1.html?NumberOfTextBoxes=" + bytBoxCount.ToString();
    RegisterStartupScript("OpenWin", "<script>openNewWin('" + url +
    "')</script>");

    In the popup1.html file:

    var bytBoxCount = bytBoxCount.ToString();
    <a onClick="self.close();" target="_blank">Thank you for entering
    <%bytBoxCount%> number of accounts<a /><br>



    "Mark Rae [MVP]" wrote:

    > "Artunc" <> wrote in message
    > news:...
    >
    > > Thank you very much, I will try this and post the results here.

    >
    > [please don't top-post]
    > http://www.caliburn.nl/topposting.html
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    >
    >
    Artunc, Jul 2, 2009
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sm9obiBXYWxrZXI=?=

    Popup Window Popup Timing

    =?Utf-8?B?Sm9obiBXYWxrZXI=?=, Nov 4, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    842
    =?Utf-8?B?Sm9obiBXYWxrZXI=?=
    Nov 4, 2005
  2. dapkniht
    Replies:
    1
    Views:
    1,330
    Eliyahu Goldin
    Mar 8, 2006
  3. Rajesh
    Replies:
    0
    Views:
    542
    Rajesh
    Jul 31, 2007
  4. Urs Gubler
    Replies:
    0
    Views:
    152
    Urs Gubler
    Jul 2, 2003
  5. Jens Peter Hansen
    Replies:
    7
    Views:
    521
    Randy Webb
    Jun 19, 2004
Loading...

Share This Page