Asp.net + jQueryRotate,
There are many online lottery programs on many websites, with various Lottery forms and a large number of Flash lotteries. This article will introduce you to the jQuery turntable lottery, combined with the code examples, jQuery and asp.net will be used to implement the turntable lottery program. For ease of understanding, the article posts the source code for implementation as a share. A lottery draw is completed by rotating the turntable pointer, And the pointer position is controlled based on the rotation angle-lucky big turntable.
1. A lucky draw first
2. Default. aspx Page code
<Span style = "font-family: Microsoft YaHei; font-size: 14px;"> <% @ 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">
We construct a user-defined function lottery (). In lottery (), we. php sends a POST request. If the winning information is returned successfully, call the rotate plug-in to start rotation. The rotation angle is determined by the angle returned by the background. Here we use 2880 + a to indicate the rotation angle, that is, the pointer is rotated in 8 circles + a degrees, and then the lottery () is called when the start lottery button is clicked, so the turntable lottery is completed.
3. data. aspx winning logic code
<Span style = "font-family: Microsoft YaHei; font-size: 14px;"> using System; using System. collections; using System. collections. generic; using System. web; using System. web. UI; using System. web. UI. webControls; public partial class data: System. web. UI. page {protected void Page_Load (object sender, EventArgs e) {Hashtable ht = new Hashtable (); Hashtable p1 = new Hashtable (); p1.Add ("id", 1 ); p1.Add ("min", 1); p1.Add ("max", 59); p1.Add ("prize", "500 points"); p1.Add ("v", 1 ); ht. add (0, p1); Hashtable p2 = new Hashtable (); p2.Add ("id", 2); p2.Add ("min", 60); p2.Add ("max ", 119); p2.Add ("prize", "100 points"); p2.Add ("v", 5); ht. add (1, p2); Hashtable p3 = new Hashtable (); p3.Add ("id", 3); p3.Add ("min", 121); p3.Add ("max ", 179); p3.Add ("prize", "10 yuan commodity"); p3.Add ("v", 5); ht. add (2, p3); Hashtable p4 = new Hashtable (); p4.Add ("id", 4); p4.Add ("min", 180); p4.Add ("max ", 240); p4.Add ("prize", "500 points"); p4.Add ("v", 10); ht. add (3, p4); Hashtable p5 = new Hashtable (); p5.Add ("id", 5); p5.Add ("min", 240); p5.Add ("max ", 300); p5.Add ("prize", "Thank you for participating"); p5.Add ("v", 80); ht. add (4, p5); Hashtable p6 = new Hashtable (); p6.Add ("id", 6); p6.Add ("min", 300); p6.Add ("max ", 360); p6.Add ("prize", "order free"); p6.Add ("v", 1); ht. add (5, p6); // Hashtable p7 = new Hashtable (); // p7.Add ("id", 7); // p7.Add ("min ", new int [6] {32, 92,152,212,272,332}); // p7.Add ("max", new int [6] {58,118,178,238,298,358}); // p7.Add ("prize ", "Thank you for participating"); // p7.Add ("v", 50); // ht. add (6, p7); // Console. writeLine (ht [0]); int htlength = ht. count; int [] proArr = new int [htlength]; foreach (DictionaryEntry single in ht) {Hashtable subObj = single. value as Hashtable; proArr [(int) single. key] = (int) subObj ["v"];} int rid = this. getRand (proArr); int jiaodu = 0; string prize = null; Hashtable res = ht [rid] as Hashtable; Random ran = new Random (); if (int) res ["id"] = 7) {int [] mins = (int []) res ["min"]; int [] maxs = (int []) res ["max"]; int I = ran. next (0, 5); jiaodu = ran. next (mins [I], maxs [I]);} else {int mins = (int) res ["min"]; int maxs = (int) res ["max"]; jiaodu = ran. next (mins, maxs);} prize = res ["prize"]. toString (); string json = "{\" angle \ ":" + jiaodu. toString () + ", \" prize \ ": \" "+ prize +" \ "}"; Response. write (json); // Dictionary <string, Dictionary <string, string> dt = new Dictionary <string, Dictionary <string, string> ();} public int getRand (int [] proArr) {int result =-1; int proSum = 0; foreach (int val in proArr) {proSum + = val;} int length = proArr. length; for (int I = 0; I <length; I ++) {Random ran = new Random (); int ranNum = ran. next (1, proSum); if (ranNum <= proArr [I]) {result = I; break;} else {proSum-= proArr [I];} return result ;}}</span>The V parameter indicates the percentage. The default value is 100. The higher the monthly value, the lower the percentage.
Add events to buttons using jquery in aspnet
Val ("aaa") must be used to change the value of a value.
Asp net jQuery form submission
No. The server-side controls are parsed into common HTML when displayed on the client. JQuery is executed on the client, so it does not store this server-side control. This is only distinguished on the server side.
Serialization failed. Check the code.