Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8235733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:54:41+00:00 2026-06-07T18:54:41+00:00

I have a .net file that utilizes a c# to process some form(post) information,

  • 0

I have a .net file that utilizes a c# to process some form(post) information, disect it, do calculations and create a string to print on screen, and send in an email.

I am getting the following error, however I am only getting it at different times. The page will work for an hour(or other random amount of time), and then will not work for a period of time.

From my .aspx file

Compiler Error Message: CS0103: The name ‘sb’ does not exist in the current context

Line 86:        <% Response.Write(sb); %>

Here is the code layout. I am including, even though I don’t think
there is an issue with the code, because it is working sometimes and
other times not. It’s as if something just has a brain lapse. I’ve looked for files to delete and can’t find anything. This is my first attempt with c#. We use it at my place of work and I’ve seen the code quite a bit, but haven’t attempted to play with it on my own.

*beginning of grade_the_quiz.aspx*

<%@ Page Language="C#" autoeventwireup="true" CodeFile="automail.aspx.cs" inherits="formsucker" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

end head / begin site layout (removed for simplicity)

<div id="contentleft">
<h1>How do you Compare?</h1>
<p>Compare yourself to your competition - how do you measure up against the best practices benchmark of the most successful Senior Living Caregivers in America?*</P>
    <form id="form1" runat="server">
    <div id="grade">        
        <% Response.Write(sb); %>
</div>         
</form>
</div>

(etc, end html, #EOF removed for simplicity)

beginning of automail.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
using System.Net;
using System.Text;


public partial class formsucker : System.Web.UI.Page
{


    public void Page_Init(object sender, EventArgs e)
    {
            string reTake = "", answerScore = "", pleaseWork = "", firstname = "", email = "";
            int noAnswer = 0, testVal = 0;

        String sdData = Request["sd"];


        string[] sdValuesSplit = sdData.Split('~');
        foreach (string postValues in sdValuesSplit)
        {
                if (postValues.Contains("FirstName"))
                {
                    firstname = postValues.Split('=')[1];

                }
                if (postValues.Contains("EMail"))
                {
                    email = postValues.Split('=')[1];

                }

                }


        StringBuilder sb = new StringBuilder();

        sb.Append("<p>Below are your results to the quiz " + firstname + ", and we will email them to " + email + " right away!</p>");

           switch (Request["CUSTOM_FORM_FIELD_11111"])
           {
               case "Yes":
                   sb.Append("<p><b>Do you have a system to track your notes, history and activity?</b></p><p><li><i>YES</i></p><p><li> Congratulations!  You are ahead of many!  You understand the value in capturing your prospects/clients critical information.  Capturing information about their history, notes and activity allows information to be shared amongst your team.  You are utilizing a power piece of the puzzle when it comes to keeping up to date with your prospects/clients</li></p>");
                   testVal = testVal + 5;
                   break;
               case "No":
                   sb.Append("<p><b>Do you have a system to track your notes, history and activity?</b></p><p><li><i>NO</i><ul><li> Consider how much time and money it cost to find new leads -- not keeping track of this information can lead to your prospects or clients falling through the cracks.  Marketing to your prospect/client does not work if you don't know what the last activity </li></p>");
                   break;
               default:
                   sb.Append("<p><b>Do you have a system to track your notes, history and activity?</b></p><p><li><i>You Didn\'t Answer the Question</i></li></p>");
                   noAnswer = noAnswer + 1;
                   break;
           }

More Switch Statements that append to sb (about 20 switch statements removed.. it’s grading a quiz and then returning different statements and appending them to sb.

  StreamWriter sw = new StreamWriter(@"C:\inetpub\websites\occupancyadvantage.com\mailTest.txt", true);
                        try
                        {

                            System.Net.Mail.MailMessage automail = new System.Net.Mail.MailMessage();
                            automail.Subject = "How Do You Compare Quiz Results";
                            automail.To.Add(email);
                            MailAddress address = new MailAddress("XXXXXXXREMOVED", "XXXXXXREMOVED");
                            automail.From = address;
                            automail.IsBodyHtml = true;
                            automail.Body = "<html><body><p>" + sb + "</p><p>XXXXXREMOVED</p>" +
                                "This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited." +
                                "<br /> XXXXXREMOVED Notifications | 2012</body></html>";
                            SmtpClient autosmtp = new SmtpClient("XXXXXREMOVED", 25);
                            NetworkCredential netCred = new NetworkCredential("XXXXXREMOVED", "XXXXXREMOVED");
                            autosmtp.Credentials = netCred;
                            autosmtp.Send(automail);

                            //SmtpMail.SmtpServer = "mail.XXXXXREMOVED.net";
                            //SmtpMail.Send(automail);

                            sw.WriteLine("Success:" + DateTime.Now.ToString());
                            sw.Close();
                            sw.Dispose();

                        }
                        catch (Exception x)
                        {
                            sw.WriteLine("Failure:" + DateTime.Now.ToString());
                            sw.WriteLine(x.ToString() + ":" + x.StackTrace.ToString());
                            sw.Close();
                            sw.Dispose();
                        }




        }
    }

If you have gotten this far, I hope I have put the most important information. I’ve searched through 20 or so of these and found different ways that this happens, just can’t find out my solution. I have created everything in notepad ++ The original site with everything going on was in VS.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:54:44+00:00Added an answer on June 7, 2026 at 6:54 pm

    For the sake of ease you could always declare a class level string, leave the Stringbuilder as is, and after all the results are appended to the object, assign the value of the Stringbuilder to the class level variable. That way you keep the Stringbuilder as is, but allow access to the information that remains after the page has loaded and the init objects expire.

     public partial class formsucker : System.Web.UI.Page
    {
        public String sbG = "";
    
        protected void Page_Init(object sender, EventArgs e)
        {
                StringBuilder sb = new StringBuilder(); 
                sb.Append("<p>" + allYourAppends + "</p>");
                sbG = sb.ToString();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have an asp.net mvc app that has a form that uploads a file.
I have a file that contain huge number of net names. I would like
I have a ID.txt file that looks like this: http://something.net/something-ak/41389_718783565_1214898307_q.jpg http://something.net/something-ak/372142_106502518141813_1189943482_q.jpg and so on
I have a batch file that will detect if the user has the .Net
I have a single XML file that I want to index using Lucene.NET. The
I have an asp.net mvc action that returns a file result. Behind the scenes,
I have an ASP.NET application that uses a custom .NET library (a .DLL file).
I have a ASP.NET MVC3 application that handles time-consuming processes (copying a large file
I have a website that uses basic ASP.Net forms authentication. In the web.config file
I'm using .NET 3.5. Say I have a method that accesses a specific file,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.