ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories >> Code-Snippets
 
 


 

Back to Questions Page
 
Question
Event Handling in C# Triggering a Button
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
using System;
using System.Windows.Forms;
using System.Drawing;

public class Butevent:Form  {
TextBox t1 = new TextBox();
Button b1 = new Button();
public Butevent() {
this.Text = "C# Program ";
t1.Location = new Point(20,30);
b1.Text = "Click here to activate";
b1.Location = new Point(20,55);
b1.Size = new Size(150,20);

     // Invoking Method or EventHandler
     b1.Click+=new EventHandler(OnClick);

     this.Controls.Add(t1);
     this.Controls.Add(b1);

     // Invoking Method or EventHandler
     this.Resize += new EventHandler(OnResize);
   }

   //Applying EventHandler
   public void OnResize(object sender,EventArgs ee) {
      MessageBox.Show("oops! Form Resized");
   }

   //Applying EventHandler
   public void OnClick(object sender,EventArgs e) {
      t1.Text = "Hello C#";
   }

   public static void Main() {
      Application.Run(new Butevent());
   }

}
 
0
Guest
 
 
Question
Automatically Hyperlink URLs and E-Mail Addresses in 
ASP.NET Pages with C#
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
using System.Text.RegularExpressions;
The second step is to detect a URL:

Regex urlregex = new Regex(@"(http:\/\/([\w.]+\/?)\S*)",
   RegexOptions.IgnoreCase|RegexOptions.Compiled);

Here is how to detect an e-mail address:

Regex emailregex = new 
Regex(@"([a-zA-Z_0-9.-]+\@[a-zA-Z_0-9.-]+\.\w+)",
   RegexOptions.IgnoreCase|RegexOptions.Compiled);



private void Button1_Click(object sender, System.EventArgs 
e)
{
   string strContent = InputTextBox.Text;
   Regex urlregex = new Regex(@"(http:\/\/([\w.]+\/?)\S*)",
                    RegexOptions.IgnoreCase| 
RegexOptions.Compiled);
   strContent = urlregex.Replace(strContent,
                "");
   Regex emailregex = new 
Regex(@"([a-zA-Z_0-9.-]+\@[a-zA-Z_0-9.-]+\.\w+)",
      RegexOptions.IgnoreCase| RegexOptions.Compiled);
   strContent = emailregex.Replace(strContent, "");
   lbContent.Text += ""+strContent;
}
 
0
Guest
 
 
Question
How to use ASP.NET 2.0's TreeView to Display Hierarchical 
Data?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
protected void TreeView1_SelectedNodeChanged(object sender, 
EventArgs e)
{
Label1.Text = "You Selected " + TreeView1.SelectedNode.Text
                                 + " category";
}
protected void Page_Load(object sender, EventArgs e)
{
   switch (Request.QueryString["id"])
   {
      case "1":
         Label1.Text="You selected ASP.NET category";
         break;
      case "2":
         Label1.Text="You selected Web Services category";
         break;
      case "3":
         Label1.Text="You selected JSP category";
         break;
      case "4":
         Label1.Text="You selected Windows Forms category";
         break;
      case "5":
         Label1.Text="You selected ActiveX category";
         break;
      case "6":
         Label1.Text="You selected Smart Client category";
         break;
      case "7":
         Label1.Text="You selected COM category";
         break;
      case "8":
         Label1.Text="You selected DCOM category";
         break;
      case "9":
         Label1.Text = "You selected Remoting category";
         break;
   }
}
 
0
Guest
 
 
 
Question
How to Create a Treeview Menu in ASP.NET with C#?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
Microsoft.Web.UI.WebControls.TreeView Treeview11 

public void PopulateTree()
{
   TreeNode nodeProdDetail, nodeProdMaster;
   nodeProdMaster      = new TreeNode();
   nodeProdMaster.Text = "Master1";
   nodeProdMaster.ID   = "1";

   nodeProdDetail             = new TreeNode();
   nodeProdDetail.Text        = "Detail1";
   nodeProdDetail.ID          = "1.1";
   nodeProdDetail.NavigateUrl = "SomePage.aspx";
   nodeProdMaster.Nodes.Add(nodeProdDetail);

   Treeview1.Nodes.Add(nodeProdMaster);

   nodeProdMaster      = new TreeNode();
   nodeProdMaster.Text = "Master2";
   nodeProdMaster.ID   = "2";

   nodeProdDetail             = new TreeNode();
   nodeProdDetail.Text        = "Detail2";
   nodeProdDetail.ID          = "2.1";
   nodeProdDetail.NavigateUrl = "SomeOtherPage.aspx";
   nodeProdMaster.Nodes.Add(nodeProdDetail);

   Treeview1.Nodes.Add(nodeProdMaster);
}
 
0
Guest
 
 
Question
How to Add Message and Confirmation Boxes Using JavaScript?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
public void AddConfirmMessage(WebControl ctl, string 
message)
{
   ctl.Attributes.Add("onclick", "if ( ! confirm( '"
      + message + "' )) return false; ");
}

public void AddPopupMessage(WebControl ctl, string message)
{
   ctl.Attributes.Add("onclick", "alert( '" + message 
+ "'); ");
}
 
0
Guest
 
 
 
Back to Questions Page
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com