Asp.net+jqueryrotate Development Lucky Big Turntable

Source: Internet
Author: User

Online lottery program on many sites, many lottery forms, flash sweepstakes, this article will introduce you to the jquery carousel draw, combined with code examples will use jquery and ASP to realize the Carousel Lottery program, in order to facilitate understanding, the article posted to realize the source code as a share. By rotating the dial hand to complete a lottery draw form, according to the angle of rotation to control the position of the pointer--lucky big turntable.

1. First Lucky Draw


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 build the Custom Function lottery (), in lottery () we send a POST request to data.php, if the winning information is successfully returned, the call rotate plug-in starts to turn, the rotation angle is determined by the angle returned from the background, here we use the 2880+ A is the angle of rotation, that is, the pointer rotates 8 laps +a, and then we call Lottery () when we click on the "Start Draw" button, so the carousel draw is complete.

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 represents a percentage, and by default the 100,v month represents the higher the winning rate, the smaller the winning rate.


Asp.net+jqueryrotate Development Lucky Big Turntable

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.