Implement the dialog box effect in webform (Asp.net)

Source: Internet
Author: User

Asp.net is a beginner who has learned how to simulate the dialog box effect,
There is a textbox and a button on the home page. click the button to bring up a modal display page.
, Enter the text, click OK to return to the home page, and return the text value.

It's very simple.

Home page:

@? Page? Language = "C #"? %>
Script? Runat = "server">

???? Private? Void? Page_load (object? Sender ,? System. eventargs? E)
???? {
???????? If? (! Ispostback)
????????? Btnopen. Attributes. Add ("onclick ",? @ "Var? Strreturn ;? Strreturn = Window. showmodaldialog ('dialogform. aspx ', null, 'status: No; dialogwidth: 250px; dialogheight: 125px; dialoghide: true; help: No; scroll: no'); If? (Strreturn ?! =? Null )? Document. getelementbyid ('txtvalue'). value = strreturn ;");
????}

SCRIPT>
Body? Ms_positioning = "gridlayout">
?? Form? Id = "form1 "? Method = "Post "? Runat = "server">
???? ASP: textbox? Id = "txtvalue "? Style = "Z-INDEX :? 101 ;? Left :? 16px ;? Position :? Absolute ;? Top :? 24px "? Runat = "server"> Asp: textbox>
???? ASP: button? Id = "btnopen "? Style = "Z-INDEX :? 102 ;? Left :? 176px ;? Position :? Absolute ;? Top :? 24px "? Runat = "server "? TEXT = "open"> Asp: button>
?? Form>
Body>

Dialog Box:

@? Page? Language = "C #"? %>
Script? Runat = "server">

???? Private? Void? Page_load (? Object? Sender ,? System. eventargs? E)
???? {
????????? If? (?! Ispostback ?)
????????? {
????????????? Btnok. Attributes. Add ("onclick ",? @ "Window. returnvalue? =? Document. getelementbyid ('txtvalue'). value ;? Window. Close ();");
????????????? Btncancel. Attributes. Add ("onclick ",? @ "Window. Close ();");
?????????}
????}

SCRIPT>
Body? Ms_positioning = "gridlayout">
?? Form? Id = "form1 "? Method = "Post "? Runat = "server">
???? ASP: textbox? Id = "txtvalue "? Style = "Z-INDEX :? 101 ;? Left :? 16px ;? Position :? Absolute ;? Top :? 24px "? Runat = "server"> Asp: textbox>
???? ASP: button? Id = "btnok "? Style = "Z-INDEX :? 103 ;? Left :? 48px ;? Position :? Absolute ;? Top :? 56px "? Runat = "server "? TEXT = "OK "? Width = "56px"> Asp: button>
???? ASP: button? Id = "btncancel "? Style = "Z-INDEX :? 102 ;? Left :? Pixel PX ;? Position :? Absolute ;? Top :? 56px "? Runat = "server "? TEXT = "cancel"> Asp: button>
?? Form>
Body>

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.