Short Tricks
* Auto Redirect concept *
- Auto Redirect with the help of < Meta > Tag.
- < Meta > use inside the < head > tag.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Z6_shorttrick_Autoredirect.aspx.cs" Inherits="ZZZAutoredirect" %>
Source Code :- Autoredirect.Aspx ( Page Or Website )
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<meta http-equiv="refresh" content="2; URL=http://nrsolution4u.com" />
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<h1><strong> this is Auto redirect concept</strong></h1>
<p>
</p>
<p>
</p>
</div>
</form>
</body>
</html>
Sorce Code :- AutoZoomConcept.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Z6_shorttrick_Autozoom.aspx.cs" Inherits="ZZZAutozoom" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function show() {
document.body.style.zoom = "200%";
}
</script>
</head>
<body onload="show()">
<form id="form1" runat="server">
<div>
this is autozoom concept<br />
<br />
</div>
</form>
</body>
</html>
Source Code :- Random Generate.aspx
- Random generator is use to generate the Random No.
- Random Generate no concept is use to Send Otp or others concepts in use.
Source Code :- Random Generate.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Z6_shorttrick_RAndomGEnerate.aspx.cs" Inherits="ZZZRAndomGEnerate" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Generate otp" />
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server" Height="31px" Width="197px"></asp:TextBox>
<br />
<br />
Generat otp randomly
</div>
</form>
</body>
</html>
ButtonCode :- Random Generate.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 ZZZRAndomGEnerate : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Random r1 = new Random();
int n = (int)(r1.NextDouble() * 9999);
TextBox1.Text = n.ToString();
}
}
* Save Any Language(Nvarchar) *
- Save any language using Nvarchar type in DATABASE .
Source Code :- Z5_languageNvarchar(hindi,marathi,etc).aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Z5_languageNvarchar(hindi,marathi,etc).aspx.cs" Inherits="Z5_language_hindi_marathi_etc_" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
font-size: large;
}
.auto-style2 {
color: #FF0000;
font-size: large;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<strong>
<h2 class="auto-style2"> <strong style="color: #000000">*</strong> How to insert any Language in Database <strong><strong style="color: #000000">*</strong></strong></h2>
</strong>
<br />
<br />
Language Name
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
Language Content
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" Height="33px" OnClick="Button1_Click" Text="Submit" Width="82px" />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<strong> Save Any language in database</strong><br />
Step :- <span class="Y2IQFc" lang="en"><span class="auto-style1">Sql datatype varchar in place of Nvarchar</span></span></div>
</form>
</body>
</html>
Button Code :- Z5_languageNvarchar(hindi,marathi,etc).aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
public partial class Z5_language_hindi_marathi_etc_ : System.Web.UI.Page
{
SqlConnection cn;
SqlCommand cm;
SqlDataAdapter dr;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string path = ConfigurationManager.AppSettings["db1"];
cn = new SqlConnection(path);
cn.Open();
string k = "insert into languag(language,Content)values(@language1,@Content1)";
cm = new SqlCommand(k, cn);
cm.Parameters.AddWithValue("language1", TextBox1.Text);
cm.Parameters.AddWithValue("Content1", TextBox2.Text);
cm.ExecuteNonQuery();
Response.Write("data submited succesfully");
}
}
* Previous Back Button Concept *
Example no : 1
Only Add Java Script use in upper < head >
<!DOCTYPE html>
<html>
<head>
<title>
Blocking Back Button
using javascript
</title>
<style type="text/css">
body {
font-family:Arial;
color:green;
}
</style>
<script type="text/javascript">
window.history.forward();
function noBack() {
window.history.forward();
}
</script>
</head>
<body>
<h1>GeeksforGeeks</h2>
<p>
Click here to Goto
<a href="b.html">
Link to second page
</a>
</p>
</body>
</html>
Example no : 2
Only Add Java Script use in upper < head >
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Backbtn.aspx.cs" Inherits="Backbtn" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function preventBack() {
window.history.forward();
}
setTimeout("preventBack()", 0);
window.onunload = function () { null };
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<a href="backbtn2.aspx">Login Using Anchor</a>
</div>
</form>
</body>
</html>
Comments
Post a Comment