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 the code:
Regex r
= new Regex(@"(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/)|(–.*)");
textBox2.Text
= r.Replace(textBox1.Text, string.Empty);
VN:F [1.1.6_502]Rating: 0.0/5 (0 votes cast)
Visual Basic.NET equivalent of C#’s typeof is GetType and NOT TypeOf
VN:F [1.1.6_502]Rating: 0.0/5 (0 votes cast)
An InfoPath template have an extension of .XSN which is simply a .CAB file. If you extract it, you will see a set of files. Basically there will be:
manifest.xsf
myschema.xsd
sampledata.xml
template.xml and
view1.xsl
I found a non-straight forward way to create the files if you have some fixed form structure. Here are the actions [...]
Here is the sample code.
private void ShowControlsFromAssembly(string assemblyfile)
{
Assembly assembly = Assembly.LoadFrom(assemblyfile);
Type[] et = assembly.GetExportedTypes();
[...]
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 [...]
I know this is an old theme but I had to write a sample app for demonstration in a tech forum. So reproducing here also.
Importantly, the DataTable/DataSet must be serializable.
ASMX Code:
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
[...]
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();
[...]