|
Hi! I'm teaching some basic ASP.NET.
I have looked at a solution for login-page.
There is the built in forms-authentication but I seem to work bad.
Login works sometimes and sometimes not. Doesn't seem so stable or maybe I am doing something wrong.
Is this something you would use on a live site?
What else should you use?
|
|
|
|
|
larsp777 wrote: Doesn't seem so stable or maybe I am doing something wrong.
Given that Forms Authentication has been around for 12 years, and is used by a huge number of sites, my money's on option 2.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Ha, ha
Maybe I should read more about it.
|
|
|
|
|
Man;
You know something, Microsoft is the opposite of stability.
Windows itself is not stable that suddenly you get that stupid blue screen and you would loss all your work. Because of that you shouldn't bet on Microsoft product so, you wont loss your money.
Help people,so poeple can help you.
|
|
|
|
|
Thankfully, I haven't seen a BSOD for years, and even then it was dodgy hardware that caused it.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes sir it's very difficult understand about the forms Authentication, I have used many time in live project, but every time new problem faced.After some searching on google some idea get, then resolve problem. I used every time web config Authentication, it's simple according to me.
|
|
|
|
|
Hello,
If I search (api/test/cusip=00163&isin=555), I get 10 records showing both of cusip and isin value and 9 records with price_type= cr and 1 record price_type= tk.
However, if I run the following query (api/test?cusip=00163&isin=555&price_type=cr), i only get results from cusip parameters (00163) and nothing from isin and they are also not in a descending order.
This is what I have so far:
public HttpResponseMessage Get([FromUri] Query query)
{
var data = db.database.AsQueryable();
int pageSize = 10;
if (query.price_type != null)
{
data = data.Where(c => c.Cover == query.price_type);
}
int total = data.Count();
var filteredData = new List<IQueryable<database_BWICs>>();
if (!string.IsNullOrEmpty(query.isin))
{
var ids = query.isin.Split(',');
foreach (string i in ids)
{
filteredData.Add(data.Where(c => c.ISINs != null && c.ISINs.Contains(i)));
}
}
if (!string.IsNullOrEmpty(query.cusip))
{
var ids = query.cusip.Split(',');
foreach (string i in ids)
{
filteredData.Add(data.Where(c => c.CUSIP != null && c.CUSIP.Contains(i)));
}
}
if (filteredData.Count != 0)
{
data = filteredData.Aggregate(Queryable.Union).OrderByDescending(c => c.UploadDate).Take(pageSize);
}
if (!data.Any())
{
var message = string.Format("No data was found");
return Request.CreateErrorResponse(HttpStatusCode.NotFound, message);
}
if (query.price_type != null)
{
data = data.OrderByDescending(c => c.Cover == query.price_type).Take(pageSize);
}
return Request.CreateResponse(HttpStatusCode.OK, new { total, data });
}
}
I have tried debugging the issue many times on the following line with search string - http://localhost:32118/api/test?cusip=00163&isin=555&price_type=cr . The application crashes on the data parameter "data = {System.Data.Entity.DbSet<multi.database>} ". I am little unclear what this issue mean?
if (query.price_type != null)
{
data = data.Where(c => c.Cover == query.price_type);
}
Am I missing something? if so, is their a better way to do this? Thanks in advance for your help and time.
modified 7-Feb-14 5:28am.
|
|
|
|
|
Sir;
I don't know what are you trying to do, but I believe that you chooses to do it with the hard way. I don't understand why you applied the each filter alone then you applied 'Union All'.
and I think that you need to mention that you are using ASP.NET MVC Web API.
Help people,so poeple can help you.
|
|
|
|
|
Hi,
I have updated my original post and managed to get half of the issue resolved. I am currently stuck on the price_type parameter on filtering query with pagesize and orderby function.
If anyone could help me out on this issue explained in my original post, that would be very helpful.
Many thanks.
|
|
|
|
|
Ma'am;
From your code, I can extract that your data table has columns:
- Cover: to be match with price type(restrict the data set)
- ISINs: filter
- CUSIP:filter
- UploadDate: descending order
first,you restrict the data to price type. Then you select ISIN matching records and the CUSIP matching ones from the restricted data. lastly, you order the filtered data according to the upload date.
After that you reorder the overall data according to the price type.
In the first request query 'cusip=00163&isin=555' you didn't specify a value for price_type so the lines
if (query.price_type != null)
{
data = data.OrderByDescending(c => c.Cover == query.price_type).Take(pageSize);
}
wont execute. But inn the request 'cusip=00163&isin=555&price_type=cr' you restrict the data to cr price type and execute the above statement which will cancel all ordering.
my recommendation is to remove these lines, and accept me as a friend on facebook.
if you need any further help you should tell me what your data is and what you want to do with it.
by the way what about the number 786?!!
Help people,so poeple can help you.
|
|
|
|
|
Thank you for your response. I am writing to inform, I manage to get the issue resolved by adding the orderby and pagesize filter to filterdata method.
Thank you for your time and suggestions.
|
|
|
|
|
Anybody familiar with Telerik's grid products...
We had code that previously implemented the telerik grid
@(Html.Telerik().Grid()<myTransactions>
.Name("Transactions")
.ClientEvents(events => events.OnLoad("TransactionsGrid_onLoad"))
.ClientEvents(events => events.OnDataBound("TransactionsGrid_onDataBound"))
.DataBinding(dataBinding => dataBinding
.Ajax()
.OperationMode(GridOperationMode.Client)
.Select("TransactionsAjax", controller))
We have recently migrated to Telerik's Kendo grid, and changed the code to the following:
@(Html.Kendo().Grid<myTransactions>()
.Name("Transactions")
.AutoBind(true)
.Events(events => events.DataBound("TransactionsGrid_onDataBound"))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Read(read => read.Action("TransactionsAjax", controller))
.PageSize(15))
In addition to the grid, the page has 3 other fields; a combobox and 2 date fields that filter the grid. The filtering works fine.
However, the printer friendly button calls TransactionsAjax for the Kendo grid and removes all filtering that was applied. The original Telerik just rendered the existing grid as print friendly without making a redundant call to TransactionsAjax.
Since the desired data to be printed is already filtered and available on the screen there is no reason to repeat the call. Is there some grid configuration setting I am missing that would stop the undesired call from happening?
|
|
|
|
|
Posting my findings in case somebody runs on to a similar issue, maybe it will be helpful (plus the code to set the select elements in the cloned div is cool ).
I've worked around the issue. Something about the first line of javascript in our printer friendly function causes the Ajax call to occur with the Kendo grid where it didn't cause it with the original Telerik grid. Changed javascript function to use jQuery clone and things are working now.
Old code:
function ShowPrinterFriendly() {
$("#printerFriendlyContent").html($("#mainContent").html());
New code:
function ShowPrinterFriendly() {
var $originalDiv = $("#mainContent");
var $clonedDiv = $originalDiv.clone();
var $originalSelects = $originalDiv.find("select");
$clonedDiv.find("select").each(function(index, item) {
$(item).val($originalSelects.eq(index).val());
});
$clonedDiv.appendTo("#printerFriendlyContent");
|
|
|
|
|
Suppose my stored procedure returns multiple datatable then how to manage that datatable in DataSet.xsd file
modified 6-Feb-14 3:30am.
|
|
|
|
|
Unfortunately If multiple result sets are retrieved through a single query, only the first result set is processed, and all other result sets are ignored.
Therefore, I suggest using one of two possibilities:
(1) Split the procedure into two separate procedures - one which returns data from EMP, and one from DEPT - and access the new procedures as two separate datasets.
(2) Union the two separate queries (with an additional column to indicate which query produced each row) and filter or conditionally format your report appropriately. The unioned query might look something like this:
SELECT EMPID ID, ENAME NAME, JOB JOB_LOC, SAL, DEPTID, 'EMP' SOURCE
FROM EMP
UNION ALL
SELECT DEPTID ID, DNAME NAME, LOC JOB_LOC, NULL SAL, DEPTID DEPTID, 'DEPT' SOURCE
FROM DEPT
|
|
|
|
|
Hello Everybody,
I would like to know if there is something I am missing why my ASP.NET is not running the script that is embedded in the master page, I imagine that it should be running in any page using the master page (where I have the event embedded) as shown in my screenshot but to my surprise it doesn't run the alert message ..
When I click any of the images I am not seeing the alert box that I am expecting as a response to the click event ..
My code is shown below .. any help much appreciated .. thanks again:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="SiteMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<title></title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<script src="Scripts/jquery-1.4.1.js" type="text/javascript" >
$('.main').ready(
function () {
alert('hello');
});
$('img').click(
function () {
alert('hello from image');
});
</script>
<script src="Scripts/myJavascriptTools.js" type="text/javascript" >
</script>
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
|
|
|
|
|
After http://www.w3schools.com/tags/tag_script.asp[^]
Quote: If the "src" attribute is present, the <script> element must be empty.
Put your script in separate element after jquery and it should run correctly.
<div class="signature">--
"My software never has bugs. It just develops random features."</div>
|
|
|
|
|
I am so excited it is starting to work .. I moved the script to a separate script tag as shown (just as you have advised) and it started showing up the "hello" message every time I open up a page attached to the master file .. yeeeey ...
$('.main').ready -------------- this event is working perfect
The way the code was written when the beautiful thing event I report happens is shown below:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="SiteMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<title></title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<script src="Scripts/jquery-1.4.1.js" type="text/javascript" >
</script>
<script type="text/javascript" >
$('.main').ready(
function () {
alert('hello');
});
$('img').click(
function () {
alert('hello from image');
});
</script>
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>
The one I find odd however is that the click event is still not getting triggered
for some reason .. so what I did next was try to change it to a different tag targeting paragraph tag instead of img but retain it in the same spot i.e.
$('p').click(
The result is that it still is not triggered when I click from a paragraph the way it was not working when I was clicking from an image using the original code which used the img tag.
So I decided to try changing the event to a mouseover instead of a click as shown below:
$('p').mouseover(
Unfortunately the event is still not get triggered when I move my mouse over the paragraph elements ..
So at this point I am thinking it does not seem to have
anything to do with the tag selector or the event type ..
I decided to experiment and move the code as close to the
page being called (I'd wish of course that it could be
centralized in just one page i.e. Site.master) but just
for the sake of experiment I tried putting the code in the
page itself that is being called as shown below:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<script type="text/javascript" >
$('p').click(
function () {
alert('hello from click of paragraph');
});
</script>
<h2>
Testing this page.
<asp:TreeView ID="TreeView1" runat="server">
</asp:TreeView>
</h2>
<p> testing paragraph1
</p>
<p>
testing paragraph2
</p>
<img src = "Image/coreTechnologies.png">
</asp:Content>
Unfortunately I still cannot get the click event to run
.. and right now I am scratching my head and trying to dig
in the books what I am still missing ... all help much appreciated ..thanks again and more power
|
|
|
|
|
You're executing the script before the browser has finished loading the body of the document, so there are no <img> or <p> tags for it to process.
The simplest solution is to make sure your script doesn't run before the body has been loaded:
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$('img').click(function(){
alert('hello from image');
});
});
</script>
It's also a good idea to move your scripts to the bottom of the page, just before the closing </body> tag.
If the content of the document might change after it's loaded, and you want the event handler to work on any new tags that get added, you can use jQuery's on method[^] to attach the handler at the document level:
$(document).on('click', 'img', function(){
alert('hello from image');
});
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Awesome ... thanks so much ... this has solved the problem I was having ...
It is my first time to ask a question here and not sure how to close a question
I do not know how to give this answer the five stars it deserves .. thumbs up in text
above indicates this to be the answer .. thanks again
|
|
|
|
|
I have 2 RadioButtonList
rdBtnPersonel_Status and rdBtnPersonel_FoodStatus
i wrote :
<asp:RadioButtonList runat="server" ID="rdBtnPersonel_Status" RepeatDirection="Horizontal" Width="100%"
DataSourceID="ObjDsPersonelStatuses" onclick="javascript:radioButtonListOnClick('<%#((RadiobuttonList)Container.FindControl("rdBtnPersonel_Status")).ClientID %>');">
</asp:RadioButtonList>
i want when i click rdBtnPersonel_Status , if the valu eual A the rdBtnPersonel_FoodStatus be disabled. (with javascript)
can any body help me?
|
|
|
|
|
I tried to change the flash banner text from 50% to 60% and its only show 60% in Desktops not in mobile.
Please let me know if any one have the solution detail and steps of how to fix it
modified 4-Feb-14 4:01am.
|
|
|
|
|
In if else structure when null arguments are passed to two string variables then it always hit the condition when i have set Var1 != "" && Var2 != "" why ? since nulls are passed to both then why it hits this condition ?
code:
public ActionResult ShowCalTextBox(String DateFrom, String DateTo)
{
if (DateFrom != "" && DateTo == "")
{
IEnumerable<GetEmpRec_DateResult> EmpRec_DateFrom = DataContext.GetEmpRec_Date(DateFrom, null).ToList();
ViewBag.Dates = "Records for"+" "+ DateFrom ;
return View(EmpRec_DateFrom);
}
else if (DateFrom == "" && DateTo != "")
{
IEnumerable<GetEmpRec_DateResult> EmpRec_DateTo = DataContext.GetEmpRec_Date(null, DateTo).ToList();
ViewBag.Dates = "Records for" + " " + DateTo;
return View(EmpRec_DateTo);
}
else if (DateFrom != "" && DateTo != "")
{
IEnumerable<GetEmpRec_DateResult> EmpRec_ByDate = DataContext.GetEmpRec_Date(DateFrom, DateTo).ToList();
ViewBag.Dates = "Records from" + " " + DateFrom +" "+"to"+" "+DateTo;
return View(EmpRec_ByDate);
}
else if (DateFrom == "" && DateTo == "")
{
IEnumerable<GetEmpRec_DateResult> EmpRec_Default = DataContext.GetEmpRec_Date(null, null).ToList();
ViewBag.Dates = "No date selection";
return View(EmpRec_Default);
}
return View();
}
it hits this one when i first browse this action or run this action.
else if (DateFrom == "" && DateTo != "")
|
|
|
|
|
null isn't "" (empty string)!!!
You should use String.IsNullOrEmpty(string_var) to check for both...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
How can I catch and retry if I got a duplicate keys error?
If InsertProviderMasterCommand failed due to dups go to GenerateKeys
and try again???
Try
GenerateKeys(myRow)
If InsertProviderMasterCommand(myRow) = True Then
MasterInsertCount += 1
End If
Catch ex As Exception
Throw ex
End Try
|
|
|
|