ASP.NET C# Personality Test -



ASP.NET C# Personality Test -

i thought code personality test in asp.net using c# fine. works , doesn't. i'm not getting syntax errors, , said, works perfectly. there logic error i'm missing?

<%@ page language="c#" debug="true" %> <!doctype html> <script runat="server"> public int m_score = 0; public int m_imagescore = 0; //displaying autopostback message selection of worklist drop-down list protected void worklistchanged(object sender, eventargs e) { if (worklist.selecteditem.text == "office work") lblwork.text = "you prefer remain within , code life away."; else if (worklist.selecteditem.text == "outdoor work") lblwork.text = "you enjoy great outdoors."; else if (worklist.selecteditem.text == "investigative work") lblwork.text = "ok, sherlock."; else if (worklist.selecteditem.text == "working people") lblwork.text = "as opposed extraterrestirals?"; else if (worklist.selecteditem.text == "work requiring travel") lblwork.text = "i can show world . . . "; else if (worklist.selecteditem.text == "helping people") lblwork.text = "you're noble spirit."; } //finding score part of image user clicked public void imagebutton_click(object sender, imageclickeventargs e) { if ((e.x > 2 && e.x < 87) && (e.y > 2 && e.y < 120)) m_imagescore = 50; else if ((e.x > 96 && e.x < 212) && (e.y > 1 && e.y < 89)) m_imagescore = 25; else if ((e.x > 2 && e.x < 87) && (e.y > 121 && e.y < 211)) m_imagescore = 10; else if ((e.x > 124 && e.x < 212) && (e.y > 94 && e.y < 218)) m_imagescore = 5; } //finding score checkbox list public void checkboxlist(object sender, eventargs e) { foreach (listitem item in checkboxlist1.items) if (item.selected) { m_score = int32.parse(item.value) + m_score; } } //finding score remaining lists public void buttonclick1(object sender, eventargs e) { m_score = textcomments.text.length + m_score; m_score = int32.parse(dropdownlist1.selecteditem.value) + m_score; m_score = int32.parse(radiobuttonlist1.selecteditem.value) + m_score; m_score = int32.parse(worklist.selecteditem.value) + m_score; int final_score = m_score + m_imagescore; if (final_score > 100) lblresults.text = "you outgoing personality type."; else if (final_score > 100 && final_score <50) lblresults.text = "you merry soul."; else if (final_score < 50 && final_score > 25) lblresults.text = "you regular kind of all-around person."; else if (final_score <25 && final_score > 0) lblresults.text = "you shy one, aren't you?"; } </script> <html> <head id="head1" runat="server"> <title>personality test</title> </head> <body> <form id="form1" runat="server"> <div> <asp:label id="lblname" text="name" associatedcontrolid="txtname" runat="server" /> <asp:textbox id="txtname" autopostback="true" runat="server" /> <br /><br /> <asp:textbox id="textcomments" text="tell me little yourself" textmode="multiline" columns="30" rows="10" runat="server" /> <br /><br /> <strong>select gender:</strong> <asp:radiobutton id="rd1male" text="male" groupname="rggender" runat="server" /> <asp:radiobutton id="rd1female" text="female" groupname="rggender" runat="server" /> <br /><br /> <strong>favorite season:</strong> <br /> <asp:dropdownlist id="dropdownlist1" runat="server" autopostback="true" > <asp:listitem value="15">spring</asp:listitem> <asp:listitem value="10">summer</asp:listitem> <asp:listitem value="20">fall</asp:listitem> <asp:listitem value="5">winter</asp:listitem> </asp:dropdownlist> <br /><br /> <strong>which of next colors favorite?</strong> <asp:radiobuttonlist id="radiobuttonlist1" runat="server"> <asp:listitem value="3">red</asp:listitem> <asp:listitem value="4">blue</asp:listitem> <asp:listitem value="7">purple</asp:listitem> <asp:listitem value="5">yellow</asp:listitem> <asp:listitem value="6">green</asp:listitem> <asp:listitem value="2">orange</asp:listitem> <asp:listitem value="8">violet</asp:listitem> <asp:listitem value="9">pink</asp:listitem> <asp:listitem value="10">brown</asp:listitem> <asp:listitem value="0">grey</asp:listitem> </asp:radiobuttonlist> <br /><br /> <strong>which type of work prefer?</strong> <br /> <asp:dropdownlist id="worklist" runat="server" autopostback="true" onselectedindexchanged="worklistchanged"> <asp:listitem value="3">office work</asp:listitem> <asp:listitem value="2">outdoor work</asp:listitem> <asp:listitem value="7">investigative work</asp:listitem> <asp:listitem value="6">woring people</asp:listitem> <asp:listitem value="5">work requiring travel</asp:listitem> <asp:listitem value="4">helping others</asp:listitem> </asp:dropdownlist> <br /> <asp:label id="lblwork" runat ="server" /> <br /><br /> <strong>which foods (check many want)</strong> <asp:checkboxlist id="checkboxlist1" runat="server" repeatcolumns="6" repeatdirection="horizontal" textalign="right"> <asp:listitem value="13">bread</asp:listitem> <asp:listitem value="14">carrots</asp:listitem> <asp:listitem value="1">ice cream</asp:listitem> <asp:listitem value="2">potato chips</asp:listitem> <asp:listitem value="5">candy bars</asp:listitem> <asp:listitem value="7">cheesecake</asp:listitem> <asp:listitem value="16">steak</asp:listitem> <asp:listitem value="9">soft drinks</asp:listitem> <asp:listitem value="15">milk</asp:listitem> <asp:listitem value="11">spaghetti</asp:listitem> <asp:listitem value="11">pizza</asp:listitem> <asp:listitem value="17">cheese</asp:listitem> <asp:listitem value="15">almonds</asp:listitem> <asp:listitem value="3">brownies</asp:listitem> <asp:listitem value="13">apples</asp:listitem> <asp:listitem value="14">oranges</asp:listitem> <asp:listitem value="15">melons</asp:listitem> <asp:listitem value="14">peas</asp:listitem> <asp:listitem value="19">brussel sprouts</asp:listitem> <asp:listitem value="15">salads</asp:listitem> <asp:listitem value="14">tuna fish</asp:listitem> </asp:checkboxlist> <br /><br /> <strong>which image appeals you?</strong> <br /> <asp:imagebutton id="imgchoice" imageurl="perstest.jpg" runat="server" onclick="imagebutton_click" /> <br /><br /><br /><br /> <asp:button id="btnpersonality" text="submit personality" runat="server" onclick="buttonclick1"/> <br /><br /> <asp:label id="lblresults" runat="server" /> </div> </form> </body> </html>

instead of using if statements determining selected item, seek using switch. give more command can have multiple cases fall through , set default.

your main problem think going come scoring. @ sec score check:

else if (final_score > 100 && final_score <50)

notice something? you're testing see if it's greater 100 , less 50. think have 2 backwards here. happens though if it's equal 100? cases greater than, or less than, none take business relationship equal match end holes. happens if it's 50? nothing. happens if it's 0? nil in these cases. might want seek like:

if (final_score > 100) lblresults.text = "you outgoing personality type."; else if (final_score <= 100 && final_score > 50) lblresults.text = "you merry soul."; else if (final_score <= 50 && final_score > 25) lblresults.text = "you regular kind of all-around person."; else if (final_score <= 25 && final_score >= 0) lblresults.text = "you shy one, aren't you?";

c# asp.net

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -