Load user controls dynamically with ASP.NET
ctrl_homegadget ctrl
= (ctrl_homegadget) LoadControl("ctrl_homegadget.ascx");
ctrl.Border = false;
ctrl.Title = "Hello";
pnlGedgets.Controls.Add(ctrl);
VN:F [1.1.6_502]Rating: 0.0/5 (0 votes cast)
ctrl_homegadget ctrl
= (ctrl_homegadget) LoadControl("ctrl_homegadget.ascx");
ctrl.Border = false;
ctrl.Title = "Hello";
pnlGedgets.Controls.Add(ctrl);
VN:F [1.1.6_502]Rating: 0.0/5 (0 votes cast)
Here is a quick script which demonstrates how to connect to TFS and get projects. Make sure you add reference to necessary dlls - Microsoft.TeamFoundation.Client and Microsoft.TeamFoundation.WorkItemTracking.Client
Imports Microsoft.TeamFoundation.Client
Imports Microsoft.TeamFoundation.WorkItemTracking.Client
Imports System.Net
Public Class Form1
Dim nc As NetworkCredential = New NetworkCredential("user", "pass")
Dim tfsurl As New Uri("http://192.168.0.2:8080")
Dim [...]
This is my trial for applying View-ViewModel concept in WPF Windows application. I do not have a Model for this sample so omitting that word
This is the XAML code which I used. Here I tried to do text binding with a TextBox and Command binding with a Button.
File 1: Window1.xaml
<Window x:Class="Window1"
[...]
DotNetZipLib is one of the best compression/zip libraries for dotnet I found. You can download it from CodePlex.
Here is a snippet which demonstrates how to use DotNetZipLib to zip and force download directly to browser.
ZipFile zip = new ZipFile();
// Add files to zip
zip.AddFile(@"C:\blah.jpg", string.Empty);
zip.AddFile(@"C:\blee.jpg", string.Empty);
// save to memory stream instead of a direct file
MemoryStream ms [...]
Again old theme but seems still people want this. Here is the code for doing this:
private void Form1_Load(object sender, EventArgs e)
{
listBox1.DataSource = new
string[] { "asdfljk", "sdfgsdfg", "xcv", "wrwerwer" };
[...]
Here is a tool for you to check if internet connection available or not. The tool uses below code for connection detection:
Download URL: http://kidoos.net/media/p/598.aspx
private bool IsInternetAvailable()
{
bool ret = false;
[...]
Here is a code snippet:
private void Form1_Load(object sender, EventArgs e)
{
this.Show();
Graphics myGraphics = this.CreateGraphics();
[...]
Here is a quick windows forms calendar code.
I used a TableLayoutPanel with Dock=Fill.
private void FillDays()
{
DateTime FirstDay = new DateTime(DateTime.Now.Year,
DateTime.Now.Month, 1);
int [...]
Here goes the sample code:
using System.IO;
using System.Management;
using System.ServiceProcess;
namespace MyTestService
{
public partial class MyTestService : ServiceBase
{
public MyTestService()
{
InitializeComponent();
[...]
An old topic but still developers asking me same… so a blog.
If you try to use a textbox or any other control in side a thread, you will get an error like this:
Cross-thread operation not valid: Control ‘textBox1′ accessed from a thread other than the thread it was created on.
To avoid that, you need [...]