Showing posts with label .NET Framework. Show all posts
Showing posts with label .NET Framework. Show all posts

Monday, April 8, 2013

Firefox postback twice problem

The problem is due to empty src attributes in the page (src="").
Removing this will solve the problem.

Monday, August 13, 2012

Access GUI from background thread using C# Forms

using System;
using System.Threading;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Threads
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        delegate void SetTextCallback(string text, int value);

        private void Form1_Load(object sender, EventArgs e)
        {
            ThreadTest t = new ThreadTest(this);
            Thread th = new Thread(t.DoWork);
            th.Start();
            //th.Join();
        
        }

        public void Populate(string text, int value)
        {

            if (this.lblMesaj.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(Populate);
                this.Invoke(d, new object[] { text,value });
                this.Invoke(d, new object[] { text,value });

            }
            else
            {
                this.lblMesaj.Text = text;
                this.progressBarFinalize.Value = value;
            }

            lblMesaj.Text = text;
        }


        private void btnSave_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }

    class ThreadTest
    {
        public delegate void populateTextBoxDelegate(string text);
        Form1 formMain;

        public ThreadTest(Form1 form)
        {
            formMain = form;
        }


        public void DoWork()
        {
            for (int i = 0; i < 1000; i++)
            {
                formMain.Populate("In progress ....", i/10);
                for (int j = 0; j < 1000; j++)
                {
                    for (int k = 0; k < 100; k++)
                    {
                        double b = Math.Sqrt(923409290423) / Math.Sqrt(423423);
                    }
                }
            }

            formMain.Populate("Thread has finished!",100);

        }
    }

}

Monday, May 28, 2012

Copy an image from internet:

private void CopyFile(string file)
        {
            WebRequest req = WebRequest.Create(@"http:....." + file);
            req.Proxy = new WebProxy("1.1.1.1", 8080);
            req.Proxy.Credentials = new NetworkCredential(@"user", "pass");
            WebResponse responsePic = req.GetResponse();
            Image webImage = Image.FromStream(responsePic.GetResponseStream()); // Error
            webImage.Save(@"D:\\pictures\" + file);
        }

Monday, March 15, 2010

Installing IIS After .NET Framework

If you install IIS after .NET framework or if you removed and reinstalled IIS on a server that has .NET framework, then your ASP.NET pages will not work.


This is because you are missing the IIS mappings associating the ASP.NET file extensions.

To fix IIS mappings for ASP.NET, follow these steps:

1. Click Start -> run -> cmd - ENTER

2. At the command prompt, type the following, and then press ENTER:

"%windir%\Microsoft.NET\Framework\version\aspnet_regiis.exe" -i

In this path, version represents the version number of the .NET Framework that you installed on your server. You need to replace with the actual version number when you type the command.

3. Register the Aspnet_isapi.dll by clicking start -> run

4. In the Open text box, type "regsvr32 %windir%\Microsoft.NET\Framework\version\aspnet_isapi.dll" and then press ENTER