Help with C# using popup pox

  • Thread starter Thread starter Artunc
  • Start date Start date
A

Artunc

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.
 
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.
 
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 said:
[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)
 
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 said:
Thank you very much, I will try this and post the results here.

[please don't top-post]
http://www.caliburn.nl/topposting.html
 
Back
Top