Use of javascript in web pages (asp.net)

Source: Internet
Author: User

Copy codeThe Code is as follows:
<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Default. aspx. cs" Inherits = "_ Default" %>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> Untitled Page </title>
<Style type = "text/css">
# Mydiv
{
Height: 89px;
}
</Style>
<Script runat = "server"> // server-side scripting language ④
Protected void Page_Load (object sender, EventArgs e)
{
Button1.Attributes. Add ("onclick", "javascript: return confirm ('Are you sure you want to delete it? ') "); // The pop-up dialog box appears when you click button1.
}
Protected void button#click2 (object sender, EventArgs e)
{
Response. Write ("is the deletion task executed !! "); // Click agree to execute or not to execute
}
</Script>
<Script language = "javascript" type = "text/javascript"> // browser script ②
Function tupian_onclick (tupian) // you need to transmit parameters to the server.
{
Tupian. src = "banner_right_02.gif"
}
Function tupian_onmouseover (tupian ){
Tupian. src = "banner_right_02.gif ";
}
Function tupian_onmouseout (tupian ){
Tupian. src = "banner_right_01.gif ";
}
</Script>
</Head>
<Body onload = "test ()"> // load the function in the script file
<Script language = "javascript"> ①
Document. write ("<font color = blue> hello, Javascript! </Font> ");
</Script> // display strings on the webpage
<Form id = "form1" runat = "server"> // form
<Div>
Onclick = "return tupian_onclick (tupian)" onmouseover = "return tupian_onmouseover (tupian)" onmouseout = "return tupian_onmouseout (tupian)/> -- parameters must be added to the server javascript script function call.
<Div id = "mydiv" onclick = "return mydiv_onclick ()"> </div> defines an ID as mydiv.
<Script src = "test. js"> // call the script file ③
</Script>
<Asp: Button ID = "Button1" runat = "server" Text = "pop-up confirmation box" onclick = "button#click2"/>
<Asp: ImageButton ID = "ImageButton1" runat = "server"
ImageUrl = "~ /Banner_right_01.gif "onclick =" ImageButton1_Click "onmouseover =" this.src?'banner_right_02.gif '"onmouseout =" this.src='banner_right_01.gif' "/>
// In the case of Class 1, the server does not respond to the mouse movement event. This method can be used to return the mouse movement time on the client.
</Div>
</Form>
</Body>
</Html>

Related Article

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.