Home All Groups Group Topic Archive Search About

Help with C# using popup pox

Author
30 Jun 2009 4:02 PM
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.

Author
30 Jun 2009 5:57 PM
Mark Rae [MVP]
"Artunc" <Art***@discussions.microsoft.com> wrote in message
news:1411CE7E-4DC1-41B1-8353-18B1FED1A304@microsoft.com...

> 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
Are all your drivers up to date? click for free checkup

Author
30 Jun 2009 6:11 PM
Artunc
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.




Show quoteHide quote
"Mark Rae [MVP]" wrote:

> "Artunc" <Art***@discussions.microsoft.com> wrote in message
> news:1411CE7E-4DC1-41B1-8353-18B1FED1A304@microsoft.com...
>
> > 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
>
>
Author
30 Jun 2009 6:22 PM
Mark Rae [MVP]
"Artunc" <Art***@discussions.microsoft.com> wrote in message
news:7B97A52D-BB80-409F-A8E4-E56FE00D19C6@microsoft.com...

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

>> 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

> 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.

Can't you just count the number of textboxes which aren't blank...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Author
30 Jun 2009 6:21 PM
Artunc
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>


Show quoteHide quote
"Mark Rae [MVP]" wrote:

> "Artunc" <Art***@discussions.microsoft.com> wrote in message
> news:1411CE7E-4DC1-41B1-8353-18B1FED1A304@microsoft.com...
>
> > 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
>
>
Author
30 Jun 2009 6:28 PM
Mark Rae [MVP]
"Artunc" <Art***@discussions.microsoft.com> wrote in message
news:B24963A7-7531-47DE-9414-6558953D527B@microsoft.com...

[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;


--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Author
30 Jun 2009 6:42 PM
Mark Rae [MVP]
"Mark Rae [MVP]" <mark@markNOSPAMrae.net> wrote in message
news:uxDvBCb%23JHA.2872@TK2MSFTNGP05.phx.gbl...

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

Apologies, that should be:
document.getElementById('<%=Accntbox1.ClientID%>').value.length;



--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Author
30 Jun 2009 6:49 PM
Artunc
Show quote Hide quote
"Mark Rae [MVP]" wrote:

> "Artunc" <Art***@discussions.microsoft.com> wrote in message
> news:B24963A7-7531-47DE-9414-6558953D527B@microsoft.com...
>
> [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)
Author
30 Jun 2009 7:03 PM
Mark Rae [MVP]
"Artunc" <Art***@discussions.microsoft.com> wrote in message
news:75E8DD63-5733-4F53-A277-BB0D5A9D67A1@microsoft.com...

> 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
Author
30 Jun 2009 9:15 PM
Artunc
Thank you very much, I will try this and post the results here.

Show quoteHide quote
"Mark Rae [MVP]" wrote:

> "Artunc" <Art***@discussions.microsoft.com> wrote in message
> news:75E8DD63-5733-4F53-A277-BB0D5A9D67A1@microsoft.com...
>
> > 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
>
>
Author
30 Jun 2009 10:11 PM
Mark Rae [MVP]
"Artunc" <Art***@discussions.microsoft.com> wrote in message
news:93356D61-DB17-4144-A328-806CEEB6C4ED@microsoft.com...

> 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
Author
1 Jul 2009 11:39 PM
Artunc
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>



Show quoteHide quote
"Mark Rae [MVP]" wrote:

> "Artunc" <Art***@discussions.microsoft.com> wrote in message
> news:93356D61-DB17-4144-A328-806CEEB6C4ED@microsoft.com...
>
> > 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
>
>

Bookmark and Share