|
Explore JQuery and Ajax.
Also follow the rules that Richard has given to make sure that whatever you do it has to adhere to best practices.
|
|
|
|
|
Has anyone tried to use the Metro-UI-CSS framework with ASP.NET 5.0 in Visual Studio Community 2015?
If so, were you successful? What parts of Metro-UI did you use? Did they work straight out of the box or did you have to add extra code to make them work?
My own experience, which was a very simple test, did not work. I was testing the "slide" capability of a tile where the text changes by sliding down when the cursor is placed within the tile. The initial condition displayed my text at the chosen font size. When the cursor was placed over the tile, the text slid down displaying the new text at my chosen font size, but it also displayed the text at the default font size over the top, thus making it unreadable.
In addition, the footer section, which should be displayed underneath the body section, was placed within the body section of the page; something I have never experienced before.
|
|
|
|
|
Isn't this effectively the same question you asked back in March[^]?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes it is, to some extent. I have now tried Metro-UI-CSS and found it to be buggy. I am now asking if anyone else has tried it and were they successful or not.
It seems to me that something fundamental is wrong if the classic footer section is placed inside the body section.
|
|
|
|
|
i'm using dropdownlist statically for gender field its not showing me proper data when im trying to update pls help..
Database doesn't contain any special Gender DB table..
Controller code for Edit:
public ActionResult Edit(int id = 0)
{
EmployeeCrud emp = new EmployeeCrud();
var empval = emp.FindById(id);
var empentity = new EmployeeEntity();
if (empval != null)
{
empentity.EmpID = empval.EmpID;
empentity.FirstName = empval.FirstName;
empentity.LastName = empval.LastName;
empentity.ContactNo = empval.ContactNo;
empentity.EmailID = empval.EmailID;
empentity.Address = empval.Address;
empentity.Dob = empval.dob;
empentity.Gender = empval.gender;
empentity.DeptName = empval.DeptName;
empentity.DeptID = empval.DeptID;
empentity.Desination = empval.desination;
empentity.Joining = empval.joining;
empentity.Salary = empval.salary;
}
ViewBag.DeptID = new SelectList(db.Depts, "DeptID", "DeptName", empentity.DeptID);
return View(empentity);
}
[HttpPost]
public ActionResult Edit(EmployeeEntity employee)
{
if (ModelState.IsValid)
{
EmployeeCrud emp = new EmployeeCrud();
var empval = emp.UpdateEmp(employee.EmpID,employee.FirstName,employee.LastName,employee.ContactNo,employee.EmailID,employee.Address,employee.Dob,employee.Gender,employee.DeptID,employee.Desination,employee.Joining,employee.Salary);
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.DeptID = new SelectList(db.Depts, "DeptID", "DeptName", employee.DeptID);
return View(employee);
}
Create View Code:
@model MvcEmpCrud3.Models.EmployeeEntity
@{
ViewBag.Title = "Create";
}
Create
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Employee</legend>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.FirstName)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.TextBoxFor(model => model.FirstName, new { placeholder = "Enter First Name here"})
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.FirstName)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.LastName)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.TextBoxFor(model => model.LastName, new { placeholder = "Enter Last Name here"})
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.LastName)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.ContactNo)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.TextBoxFor(model => model.ContactNo, new { placeholder = "Enter Contact No here"})
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.ContactNo)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.EmailID)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.EmailID, new { placeholder = "Enter EmailId here" } )
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.EmailID)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Address)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.TextAreaFor(model => model.Address, new { style = "width: 300px; height: 70px;", placeholder = "Enter title here" })
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Address)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Dob)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.Dob)
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Dob)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Gender)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.DropDownList("Gender", new List<SelectListItem>{
new SelectListItem{ Text="Male", Value="Male"},
new SelectListItem{ Text="Female", Value="Female"}
},"Select Gender")
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Gender)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.DeptID, "Dept")
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.DropDownList("DeptID",@ViewBag.DeptID as SelectList,"Select Department")
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.DeptID)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Desination)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.TextBoxFor(model => model.Desination, new { <a href="http://www.codeproject.com/Members/placeholder">@placeholder</a> = "Enter Designation here"})
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Desination)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Joining)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.TextBoxFor(model => model.Joining)
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Joining)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Salary)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.TextBoxFor(model => model.Salary, new { <a href="http://www.codeproject.com/Members/placeholder">@placeholder</a> = "Enter Salary here"})
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Salary)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
@Html.ActionLink("Back to List", "Index")
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<a href="http://www.codeproject.com/Members/scripts">@Scripts</a>.Render("~/bundles/jqueryui")
<a href="http://www.codeproject.com/Members/Styles">@Styles</a>.Render("~/Content/themes/base/css")
<"script type="text/javascript">
$(document).ready(function () {
$("#Dob").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'dd/mm/yy'
});
$("#Joining").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'dd/mm/yy'
});
});
</script>
}
Edit View Code:
@model MvcEmpCrud3.Models.EmployeeEntity
@{
ViewBag.Title = "Edit";
}
Edit
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Employee</legend>
<a href="http://www.codeproject.com/Members/html">@Html</a>.HiddenFor(model => model.EmpID)
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.FirstName)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.FirstName)
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.FirstName)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.LastName)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.LastName)
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.LastName)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.ContactNo)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.ContactNo)
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.ContactNo)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.EmailID)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.EmailID)
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.EmailID)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Address)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.Address)
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Address)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Dob)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.TextBoxFor(model => model.Dob)
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Dob)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Gender)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.DropDownListFor(model => model.Gender, new List<SelectListItem> {new SelectListItem{Text="Male",Value="Male"},new SelectListItem{Text="Female",Value="Female"} })
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Gender)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.DeptID, "Dept")
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.DropDownList("DeptID", String.Empty)
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.DeptID)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Desination)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.Desination)
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Desination)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Joining)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.TextBoxFor(model => model.Joining)
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Joining)
</div>
<div class="editor-label">
<a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Salary)
</div>
<div class="editor-field">
<a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.Salary)
<a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Salary)
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
}
@Html.ActionLink("Back to List", "Index")
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<a href="http://www.codeproject.com/Members/scripts">@Scripts</a>.Render("~/bundles/jqueryui")
<a href="http://www.codeproject.com/Members/Styles">@Styles</a>.Render("~/Content/themes/base/css")
<"script type="text/javascript">
$(document).ready(function () {
$("#Dob").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy"
});
$("#Joining").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy"
});
});
</script>
}
|
|
|
|
|
You just dumped a ton of code. You need to narrow it down to specific code and then ask a specific question.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
All I could see that you are using the same SelectList for Gender dropdown. What is your error? Unless you specify exactly what issue you are facing we cannot help you.
Are you expecting the dropdown showing the correct gender by default while Edit view in the page?
|
|
|
|
|
im expecting what is the data(male or Female) on edit field that should be come on dropdown list..
|
|
|
|
|
I would suggest you implement the same logic as you have done for Dept dropdown. GEnerate the select list in the action and set the selected gender in the select list before sending to View.
|
|
|
|
|
Hi to Everyone
What I want to do is read from a database a list of already entered data which has a date as part of the record, I am fine with that, then using the standard ASP controls + free AJAX controls or other free controls where there is no caveat to their use.
Display in a calendar control or the like a standard month style layout but with all the previously used/ selected days highlighted in some way so the user knows what dates have been previously used.
So with the current date being 09/May/2015 (UK Time) if data had been previously entered against
(02/05/2016), (05/05/2016), (08/05/2016)
Those days would be highlighted in the calendar control or similar
I could of course provide a side list of previously used dates in a separate control but where is the challenge in that.
I am not a seasoned ASP person my background is desktop development in VB3, VB5, VB6 VB.Net and C# and T-SQL so I know a thing or two about programming just not the ASP controls or what they can accomplish.
Thanks to all who reads this
|
|
|
|
|
Most calendars support what you are trying to do. What calendar control are you using? JQuery , that sort ?
|
|
|
|
|
Good day
We have a asp.net website high traffic website. When a user registers we store the ip address i that user,when the login we store all ip addreses he used and we have a blocking module which blocks a username and all the ip's associated with that username. So that those who want to create other accounts from same location will be blocked. This morning we had few incidents where we needed to block the fake user. Can anyone scrutinise my approach and there is anything to my approach that i can add to make it rock solid i would appreciate. We also have a mobile app which also does the same in terms of Imei and it blocks the phones which is easy.
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vimalsoft.com
vuyiswa[at]vimalsoft.com
|
|
|
|
|
You can ask Chris how hard it is to block the same user, based on data from some previously banned account...
As you may already know IP banning has it disadvantages, but to be honest, there is no really reliable method to block new users based on old data...
No IP address, no email, no user-name and nothing other will for sure connect one account to an other, so always will miss someone bad, why probably block someone innocent...
So with all the sorrow - there is no 'rock solid' solution, but bad and worst only...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Unfortunately it is very hard to identify the users using IP addresses because for some ISPs all customers might have similar IP address. The only way of doing this is installing small programs in the browser and getting their MAC address which is unique for all users but which is not possible without user permission.
|
|
|
|
|
I'm trying to use gSOAP with C++ to pass a std::list of a simple structure using the soapstd2 compiler to generate the relevant WSDL for a legacy application that I'm trying to offer as a web service.
Heres the gSOAP header that I have defined in the legacy C++ app:
#import "stl.h"
class ns__arpaTarget
{
public:
int nTgtNo;
std::string name;
double dRange;
double dBearing;
ns__arpaTarget();
~ns__arpaTarget();
};
class ns__arpaList
{
public:
std::list <ns__arpaTarget> arpa_lst;
};
int ns__getArpaList( ns__arpaList* lst );
I'm compiling this within Visual Studio 2008, with the following pre build event to generate the WSDL:
W:\gSOAP\gsoap-2.8\gsoap\bin\win32\soapcpp2 -I W:\gSOAP\gsoap-2.8\gsoap\import -t W:\gSOAP\gsoap-2.8\gsoap\WS\typemap.dat -j -s gSOAPArpaWebService.h
This is all building fine at the server end (I have an implementation of the function which builds and runs and supplies a list of my simple structure) - it's also generating the WSDL which looks like this:
="1.0"="UTF-8"
<definitions name="Arpa"
targetNamespace="http://localhost:5801/arpa.wsdl"
xmlns:tns="http://localhost:5801/arpa.wsdl"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns="http://localhost:5801/arpa.wsdl"
xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:HTTP="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:MIME="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:DIME="http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/"
xmlns:WSDL="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<schema targetNamespace="http://localhost:5801/arpa.wsdl"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns="http://localhost:5801/arpa.wsdl"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="arpaTarget">
<sequence>
<element name="nTgtNo" type="xsd:int" minOccurs="1" maxOccurs="1"/>
<element name="name" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<element name="dRange" type="xsd:double" minOccurs="1" maxOccurs="1"/>
<element name="dBearing" type="xsd:double" minOccurs="1" maxOccurs="1"/>
</sequence>
</complexType>
<element name="getArpaList">
<complexType>
<sequence>
</sequence>
</complexType>
</element>
<element name="arpaList">
<complexType>
<sequence>
<element name="arpa-lst" type="ns:arpaTarget" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
</schema>
</types>
<message name="getArpaList">
<part name="Body" element="ns:getArpaList"/>
</message>
<message name="arpaList">
<part name="Body" element="ns:arpaList"/>
</message>
<portType name="ArpaPortType">
<operation name="getArpaList">
<documentation>Service definition of function ns__getArpaList</documentation>
<input message="tns:getArpaList"/>
<output message="tns:arpaList"/>
</operation>
</portType>
<binding name="Arpa" type="tns:ArpaPortType">
<SOAP:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getArpaList">
<SOAP:operation soapAction=""/>
<input>
<SOAP:body parts="Body" use="literal"/>
</input>
<output>
<SOAP:body parts="Body" use="literal"/>
</output>
</operation>
</binding>
<service name="Arpa">
<documentation>service described at http://localhost:5801/ArpaService</documentation>
<port name="Arpa" binding="tns:Arpa">
<SOAP:address location="http://localhost:5801/arpaserver.cgi"/>
</port>
</service>
</definitions>
At the client end I'm referencing the generated gSOAP WSDL and successfully importing the service via an ASP.NET web application - but when I try to use the service function of the imported service to retrieve the list of ns__arpaTarget types the service only offers the following function signature that I don't understand or know how to use (perhaps this is my problem?):
Radar_Services_Web_Client.ArpaSrv.arpaTarget[] ArpaPortTypeClient.getArpaList( Radar_Services_Web_Client.ArpaSrv.getArpaList getArpaList1 )
Note: I have tried this without a list and I am able to get a single structure out from the service into the client call successfully. I've also tried a list of pointers to ns__arpaTarget - as the gSOAP documentation tells me this is a safer way of doing so but the same problem occurs (i.e. I get the same strange signature to use in the client).
Any help would be greatly appreciated. Many thanks, Gary.
|
|
|
|
|
Error Is: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
controller code:
public ActionResult Edit(int id = 0)
{
Student1 student1 = new Student1();
StudentCRUD stud = new StudentCRUD();
var st = stud.SelectById(id);
if (st != null)
{
student1.First_Name = st.First_Name;
student1.Middle_Name = st.Middle_Name;
student1.Last_Name = st.Last_Name;
student1.Contact_No = st.Contact_No;
student1.Email_ID = st.Email_ID;
student1.Temp_Address = st.temp_Address;
student1.Permanant_Address = st.permanant_address;
student1.CountryName = st.CountryName;
student1.StateName = st.StateName;
student1.CityName = st.CityName;
}
ViewBag.CityID = new SelectList(db.Cities, "CityID", "CityName", student1.CityID);
ViewBag.CountryID = new SelectList(db.Countries, "CountryID", "CountryName", student1.CountryID);
ViewBag.StateID = new SelectList(db.States, "StateID", "StateName", student1.StateID);
return View(student1);
}
StudentCRUD Class:
public Sp_FindbyId_Result SelectById(Nullable<int> stid)
{
var stud = db.Sp_FindbyId(stid).ToList();
return (stud[0]); // Error coming here
}
|
|
|
|
|
That means there are no entries in your list. You need to use your debugger to find out why you did not retrieve any records.
|
|
|
|
|
First check that the method "db.Sp_FindbyId(stid)" return any value or not.
this exeception is because in code var stud = db.Sp_FindbyId(stid).ToList();
stud is not having any recored.
In this case better to use
return (stud.FirstOrDefault())
|
|
|
|
|
Thanks ...Richard MacCutchan & Kunwar Bahadur Singh
|
|
|
|
|
You could put a check before accessing the value from the list
var stud = db.Sp_FindbyId(stid).ToList();
if (stud.Count() > 0 ){
return (stud[0]);
}else{
}
|
|
|
|
|
FirstOrDefault will do exactly the same thing, as suggested in the reply above yours.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I agree , that will do as well. Thanks for pointing out to me. I think I overlooked the last line.
|
|
|
|
|
Hello
I have been trying for some time to log-in to a site who register.aspx page works (new user's details are inserted in the database).
However, when I use those same details of a user (email and password) to log-in, I am not able to. I get no debug errors in Visual Studio 2013 for Web or server errors. The form just stands still when I click the logon button.
Are there are glaring errors, please, in my log-on code? In my aspx file, the two form fields are ID = strEmail and ID = password:
Protected Sub LogonBtn_Click(sender As System.Object, e As System.EventArgs) Handles LogonBtn.Click
Try
Using conn As OleDbConnection = New OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings("students").ConnectionString)
conn.Open()
Dim strEmailValue As String = strEmail.Text
Dim passwordValue As String = password.Text
Dim MSAccess As String = "Provider=Microsoft.Jet.OleDb.4.0; Data Source=|DataDirectory|students.mdb;"
Dim ConnectionString As String = "SELECT * FROM university WHERE strEmail = '" & strEmailValue & "' AND [password] = '" & passwordValue & "'"
Dim cmd As New OleDbCommand
Dim reader As OleDbDataReader = cmd.ExecuteReader
Dim strEmailFound As Boolean = False
Dim passwordFound As Boolean = False
'if in database:
While reader.Read
strEmailFound = True
strEmailValue = reader("strEmail")
passwordFound = True
passwordValue = reader("password")
End While
conn.Close()
'check result
If strEmailFound = True And passwordFound = True Then
Dim target = String.Format("~/userpage.aspx?strEmail={0}", strEmailValue)
Response.Redirect(target, True)
End If
End Using
Catch ex As Exception
Console.WriteLine(ex.Message)
Dim MessageBox As String
MessageBox = "Sorry, email or password not found"
End Try
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Dim strEmailValue As String = ""
'Dim strEmailValue As String = strEmail.Text
If Not IsPostBack Then
strEmail.Text = String.Format("{0}", Request.QueryString("strEmail"))
End If
LblDate.Text = ReturnDate()
strEmail.Focus()
End Sub
End Class
Many thanks!
|
|
|
|
|
Apart from the potential for SQL injection problems with your database, do you really want to store passwords in clear text?
[edit]
Also look at the following sequence:
While reader.Read
strEmailFound = True
strEmailValue = reader("strEmail")
passwordFound = True
passwordValue = reader("password")
End While
You are setting both variables to True without actually checking whether you have found the specific entries in the database. You need to read through your code carefully and check your logic.
[/edit]
|
|
|
|
|
Hello Richard
Many thanks for your reply.
Yes, there are a couple of flaws - plain text passwords as opposed to salting/hashing, and empty form fields - but for the moment I just wanted to get the engine started and then, when I can log in, I will explore those other important features of a log-in form.
Thanks for pointing out the While reader.Read/End While
You mean it's not actually doing anything?!
Thanks again for your reply.
|
|
|
|
|