answersLogoWhite

0

What else can I help you with?

Continue Learning about Engineering

What does the 'does not exist in current context' error mean in c sharp?

It means you are trying to modify an entity from outwith the scope of that entity. The following shows an example: public void button1_Click(object sender, EventArgs e) { int x = 42; timer1.Start(); } public void timer1_Tick(object sender, EventArgs e) { if (x==42) // error: x does not exist in current context { // do something... } } Here, the x variable is declared local to the button1_Click event. That is; it is scoped to that function and is only accessible within the context of that function. The timer1_Tick event is a separate function, outwith the scope of the button1_Click event. As such, the timer1_Tick function cannot access x. In order for both functions to access variable x, that variable must be declared in a scope that is accessible to both functions. Given that both functions are members of the same class, it would make sense to declare x at class scope: int x = 0; public void button1_Click(object sender, EventArgs e) { x = 42; timer1.Start(); } public void timer1_Tick(object sender, EventArgs e) { if (x==42) { // do something... } } Note that the point of declaration defines the scope of the declared entity and that the scope defines the context in which that entity is visible.


How do you handle error when you click on a link?

If you are referring to handling a link to a page that does not exist, then you can't unless the link was pointing to your application, in which case you can handle it in the Application_Error event in global.asax. If you are referring to handling a link that causes a postback to your application, and then having an error occur in the Click event, you can trap your logic around a try/catch/finally block. Eg: protected void Link_Click(object sender, EventArgs e) { try { // Do something stupid a = 1/0; } catch (Exception ex) { ErrorMessage.Text = "Whoops, something went wrong!"; } }


How to make progress bar in C sharp?

Using visual studio, First you have to drag a progress bar from the toolbox into your application design view, in the properties panel you can see the name of the progress bar it could be "progressBar1" choose a function of your application where you want to put it, you can type. progressBar1.Minimum = 0; progressBar1.Maximum = 100; progressBar1.Step = 100; progressBar1.PerformStep(); So it could look like this, the progress bar will load when you run the application private void Form1_Load(object sender, EventArgs e) { progressBar1.Minimum = 0; progressBar1.Maximum = 100; progressBar1.Step = 100; progressBar1.PerformStep(); }


Difference between arraylist and array?

Terms from computer science: You can imagine list like as string of pearls. They are connected with thread. If you got one you can go by thread to the other one next to it. An array is like a meter. You know where you are so you can jump any amount of units around.


Related Questions

What does the 'does not exist in current context' error mean in c sharp?

It means you are trying to modify an entity from outwith the scope of that entity. The following shows an example: public void button1_Click(object sender, EventArgs e) { int x = 42; timer1.Start(); } public void timer1_Tick(object sender, EventArgs e) { if (x==42) // error: x does not exist in current context { // do something... } } Here, the x variable is declared local to the button1_Click event. That is; it is scoped to that function and is only accessible within the context of that function. The timer1_Tick event is a separate function, outwith the scope of the button1_Click event. As such, the timer1_Tick function cannot access x. In order for both functions to access variable x, that variable must be declared in a scope that is accessible to both functions. Given that both functions are members of the same class, it would make sense to declare x at class scope: int x = 0; public void button1_Click(object sender, EventArgs e) { x = 42; timer1.Start(); } public void timer1_Tick(object sender, EventArgs e) { if (x==42) { // do something... } } Note that the point of declaration defines the scope of the declared entity and that the scope defines the context in which that entity is visible.


How do you disable copy and paste option from textbox?

Try to handle the SelectionChanged event of the RichTextBox, and then deselect the selected content, as shown below: private void richTextBox1_SelectionChanged(object sender, EventArgs e) { if (richTextBox1.SelectionStart != richTextBox1.TextLength) { richTextBox1.SelectionStart = richTextBox1.TextLength; } }


How do you handle error when you click on a link?

If you are referring to handling a link to a page that does not exist, then you can't unless the link was pointing to your application, in which case you can handle it in the Application_Error event in global.asax. If you are referring to handling a link that causes a postback to your application, and then having an error occur in the Click event, you can trap your logic around a try/catch/finally block. Eg: protected void Link_Click(object sender, EventArgs e) { try { // Do something stupid a = 1/0; } catch (Exception ex) { ErrorMessage.Text = "Whoops, something went wrong!"; } }


How to make progress bar in C sharp?

Using visual studio, First you have to drag a progress bar from the toolbox into your application design view, in the properties panel you can see the name of the progress bar it could be "progressBar1" choose a function of your application where you want to put it, you can type. progressBar1.Minimum = 0; progressBar1.Maximum = 100; progressBar1.Step = 100; progressBar1.PerformStep(); So it could look like this, the progress bar will load when you run the application private void Form1_Load(object sender, EventArgs e) { progressBar1.Minimum = 0; progressBar1.Maximum = 100; progressBar1.Step = 100; progressBar1.PerformStep(); }


Who can you stored the image in database and then retrive it?

We can store images as well as files in database. Use this code for Onclick event of upload button :- protected void btnUpload_Click(object sender, EventArgs e) { string strImageName = txtName.Text.ToString(); if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "") { byte[] imageSize = new byte[FileUpload1.PostedFile.ContentLength]; HttpPostedFile uploadedImage = FileUpload1.PostedFile; uploadedImage.InputStream.Read(imageSize, 0, (int)FileUpload1.PostedFile.ContentLength); // Create SQL Connection SqlConnection con = new SqlConnection(); con.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; // Create SQL Command SqlCommand cmd = new SqlCommand(); cmd.CommandText = "INSERT INTO Images(ImageName,Image) VALUES (@ImageName,@Image)"; cmd.CommandType = CommandType.Text; cmd.Connection = con; SqlParameter ImageName = new SqlParameter("@ImageName", SqlDbType.VarChar, 50); ImageName.Value = strImageName.ToString(); cmd.Parameters.Add(ImageName); SqlParameter UploadedImage = new SqlParameter("@Image", SqlDbType.Image, imageSize.Length); UploadedImage.Value = imageSize; cmd.Parameters.Add(UploadedImage); con.Open(); int result = cmd.ExecuteNonQuery(); con.Close(); if (result > 0) lblMessage.Text = "File Uploaded"; GridView1.DataBind(); } }


Difference between arraylist and array?

Terms from computer science: You can imagine list like as string of pearls. They are connected with thread. If you got one you can go by thread to the other one next to it. An array is like a meter. You know where you are so you can jump any amount of units around.