Nothing Special   »   [go: up one dir, main page]

Using Using Using Using Using Using Using Using Using Namespace Public Partial Class

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

15:

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

namespace menustrip_demo
{
public partial class Form1 : Form
{
String s;
public Form1()
{
InitializeComponent();
}

private void copyToolStripMenuItem_Click(object sender, EventArgs e)


{
s = textBox1.Text;
}

private void cutToolStripMenuItem_Click(object sender, EventArgs e)


{
s = textBox1.Text;
textBox1.Text = null;
}

private void pasteToolStripMenuItem_Click(object sender, EventArgs e)


{
label1.Text = s;
}

private void textboxToolStripMenuItem_Click(object sender, EventArgs e)


{
TextBox tb;

tb = new TextBox();
this.Controls.Add(tb);

private void labelToolStripMenuItem_Click(object sender, EventArgs e)


{
Label lb;

lb = new Label();
this.Controls.Add(lb);

private void undoToolStripMenuItem_Click(object sender, EventArgs e)


{
textBox1.Text = s;
}
}
}
Output:

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

namespace base_mdi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
Form2 f2 = new Form2();
f2.Show();
f2.MdiParent = this;
}

private void Form1_Load(object sender, EventArgs e)


{
IsMdiContainer = true;
}
}
}

Output:
19:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{

protected void Button1_Click(object sender, EventArgs e)


{
if (Request.Form["textbox1"] == null ||
string.IsNullOrWhiteSpace(Request.Form["textbox1"]))
{
if (Request.Form["textbox2"] == null ||
string.IsNullOrWhiteSpace(Request.Form["textbox2"]))
{
Response.Write("error");
}
Response.Write("error");
}
else
{
Response.Write("Welcome");
}
}
}
20:

Web.config

<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
</system.web>
</configuration>

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"


Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>


<asp:Button ID="Button1" runat="server" Text="Change
Color" />

</div>
</form>
</body>
</html>

Default.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
if (Label1.ForeColor != System.Drawing.Color.Red)
{
Label1.ForeColor = System.Drawing.Color.Red;
}
else
{
Label1.ForeColor = System.Drawing.Color.Yellow;

}
}
}
Output:

21:

Web.config

<?xml version="1.0"?>

<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->

<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>

</configuration>

Webform1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="enable_disable_textbox.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>


<asp:Button ID="Button1" runat="server" Text="Enable"
/>

</div>
</form>
</body>
</html>

Webform1.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace enable_disable_textbox
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Enabled = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (Button1.Text == "Enable")
{
Button1.Text = "Disable";
TextBox1.Enabled = true;
TextBox1.Width = 500;
}
else {
Button1.Text = "Enable";
TextBox1.Enabled = false;
TextBox1.Width = 100;
}
}
}
}

Output:

You might also like