Rational use of JavaScript and CSS in Asp.net

Source: Internet
Author: User

Wahstyle.css File

Body
{
Background-color: Aqua;
}
. Tab
{
Background-color: yellow;
}
. Txtlogin
{
Border-top-width: 0px;
Border-left-width: 0px;
Border-right-width: 0px;
Border-bottom-width: 1px;
Border-bottom-color: black;
Background-color: yellow;
}

Wahjs. JS File

// JScript File
Window. onload = load;
Function load ()
{
VaR mycss = Document. getelementbyid ("mycss ");
Mycss. setattribute ("href", "CSS/wahstyle.css ");
VaR txtname = Document. getelementbyid ("textbox1 ");
Txtname. attachevent ('onkeypress ', nameenter );
Txtname. Focus ();
}

Function nameenter ()
{

If (event. keycode = 13)
{
VaR txtpass = Document. getelementbyid ("textbox2 ");
Txtpass. Focus ();
}
}
// Login. ASPX page

<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default. aspx. cs" inherits = "_ default" %>

<! Doctype HTML public "-// W3C // DTD
XHTML 1.0 transitional // "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>
<Link id = "mycss" rel = "stylesheet" type = "text/CSS"/>
<Script language = "JavaScript" src = "JS/wahjs. js"> </SCRIPT>

<Script language = "JavaScript" type = "text/JavaScript">
Function mysubmit ()
{
If (event. keycode = 13)
{
_ Dopostback ("button1 ","");
}


}
</SCRIPT>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Table class = "tab">
<Tr>
<TD>
Name
</TD>
<TD>
<Asp: textbox id = "textbox1" cssclass = "txtlogin" runat = "server"> </ASP: textbox>
</TD>
</Tr>
<Tr>
<TD>
Password
</TD>
<TD>
<Asp: textbox id = "textbox2" onkeypress = "mysubmit ();" cssclass = "txtlogin" runat = "server"> </ASP: textbox>
</TD>
</Tr>
<Tr>
<TD>
</TD>
<TD>
& Nbsp;
<Input id = "button1" runat = "server" onserverclick = "button2_serverclick" type = "button"
Value = "login"/> </TD>
</Tr>
</Table>

</Div>
<Asp: dropdownlist id = "dropdownlist1" runat = "server" width = "0px" autopostback = "true">
</ASP: dropdownlist>
</Form>
</Body>

</Html>

//. CS File

Http://download.csdn.net/source/670982

 

Using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;

Public partial class _ default: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{

}
Protected void button2_serverclick (Object sender, eventargs E)
{
Response. Write ("name:" + this. textbox1.text + "Pass:" + this. textbox2.text );
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.