|
here i got bit code for signalr and included.
client code
$(function () {
var chat = $.connection.chat;
chat.addMessage = function (message) {
$('#messages').append('<li>' + message + '');
};
$("#broadcast").click(function () {
chat.send($('#msg').val());
});
$.connection.hub.start();
});
server code
public class Chat : Hub
{
public void Send(string message)
{
Clients.addMessage(message);
}
}
just see this line Clients.addMessage(message); addMessage() will invoke addMessage() function in client side but think suppose when i am sending data or message to specific client and if that is client is not connected any more then what will happen?
is there any provision in signalr like can we determine that client is connected before delivering data to specific client.
i want to detect a specific client is connected or not before sending data to client. if client is not connected then i will store data in db for that specific user. please help me with sample code that how to detect a specific client is connected or not? thanks
tbhattacharjee
|
|
|
|
|
Imports Microsoft.AspNet.Identity
Imports Microsoft.AspNet.Identity.EntityFramework
Imports Microsoft.AspNet.Identity.Owin
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports Microsoft.Owin.Security
Partial Public Class Account_Login
Inherits Page
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
RegisterHyperLink.NavigateUrl = "Register"
OpenAuthLogin.ReturnUrl = Request.QueryString("ReturnUrl")
Dim returnUrl = HttpUtility.UrlEncode(Request.QueryString("ReturnUrl"))
If Not [String].IsNullOrEmpty(returnUrl) Then
RegisterHyperLink.NavigateUrl += "?ReturnUrl=" & returnUrl
End If
End Sub
Protected Sub LogIn(sender As Object, e As EventArgs) Handles btnLogin.Click
If IsValid Then ' Validate the user password
Dim manager = New UserManager()
Dim user As ApplicationUser = manager.Find(username.Text, password.Text)
Try
If user IsNot Nothing Then
IdentityHelper.SignIn(manager, user, RememberMe.Checked)
IdentityHelper.RedirectToReturnUrl(Request.QueryString("ReturnUrl"), Response)
End If
Catch ex As Exception
FailureText.Text = ex.Message
ErrorMessage.Visible = True
End Try
End If
End Sub
End Class
No error message is generated but when I complete the log-in form nothing happens after I press the Submit button.
When the user logs in and his credentials are validated against the database, the form should ideally disappear and
the user is sent to a Classic ASP Web site already on the WWW. That is, that particular Web site is not part of this small ASP.NET project whose pages will be 'sellotaped' onto that Classsic ASP site. (Eventually, I may try to do that site in ASP.NET but it would be too ambitious for me to try it now.)
How would I code that in my Login.aspx.vb file, or add to the script above, because in the script above there is no reference to a URL path as in 'when you click
on the Go/Submit button, make this log-in form disappear, and take me to www.mysite.com'?
Thanks for reading.
|
|
|
|
|
Member 8761667 wrote: RegisterHyperLink.NavigateUrl = "Register"
Should that be "Register.aspx" or something with an extension
|
|
|
|
|
Hello 8761667
Thanks for your reply.
I have tried it with "Register.aspx" and debugged and got no errors. My Log-in form popped up and I entered the name and password of a user in the database. It searched for a few seconds - at least that's what I think it was doing behind the scenes - before the username remained in its field and the password disappeared.
I did exactly the same but this time only with "Register". Again, no errors. I completed the form again and the same happened, only quicker.
I don't get any errors such as 'username/password invalid'.
Could the form actually be working, but it does not know where to direct the user to as I have not stimulated a kind of 'if credentials are correct send the user to www.mysite.com' type of script?
Thanks again.
|
|
|
|
|
I've never coded in entity framework.
but you should be able to run the code in visual studio
select the line you want to start at by pressing F9, and the line will turn yellow
Press F5, and run the code in the web dev server, and you should be able to walk the code by
pressing F11, to go 1 line at a time.
From there, you can see what happens
I suspect the if Page.IsValid doesn't really work and the page does nothing, and the username stays but the password is cleared which is normal behavior for nothing happening.
|
|
|
|
|
Hello jkirkerx
Thanks for your reply.
With my cursor flashing before the If IsValid, the line turns brown alongside a large red dot after pressing F9. I press F5 and the cursor jumps to this line above my If IsValid:
Protected Sub Page_Load(sender As Object, e As EventArgs)
That line is highlighted in yellow alongside a large red dot with a yellow arrow inside. I press F11 two or the times and it moves down highlighting lines in yellow until it jumps to this:
Protected Sub Page_Load(sender As Object, e As EventArgs)
in Site.master, and after a couple more F11s, it shows this:
Protected Sub Page_Load(sender As Object, e As EventArgs) in a file called 'OpenAuthProviders.ascx.vb, and then it starts to go through modernizr-2.6.2.js
It cursor/yellow lines seem to be jumping all over the place!
|
|
|
|
|
That happens.
Set a break point on Page.IsValid, then set another on the line below, when the first one hits, press F5 to skip to the next break point, and see if that hits.
F11 walks, F5 executes to until a break point is found.
If it doesn't break on the 2nd break point, then the page is not valid.
Sometimes you can't walk code, or the code breaks to other code pages before you get to what you want. So You have to strategize on setting breakpoints.
You'll get better at it, over time.
|
|
|
|
|
OK, there are two breakpoints:
If IsValid Then
Dim manager = New UserManager()
When I then press F5 here: If IsValid it quickly loads up the browser and highlights everything in yellow in that modernizr js file.
It didn't go from one breakpoint to the other, so that would indicate an invalid file, do you think?
|
|
|
|
|
I think it's running the page validator script now, you'll have to see if the script runs to the end and get to Dim manager = new UserManager(), put a breakpoint there
|
|
|
|
|
It looks to me as if it has stopped. In the very bottom left of the software it says 'Ready'. Everything has stopped in modernizr. It has stopped here at the very top of modernizr:
window.Modernizr = (function( window, document, undefined ) {
and has a red spot next to it with a yellow arrow inside it, and the Immediate Window is blank.
|
|
|
|
|
Hi everyone.
I am well and truly stuck.
I have created a huge list of radio buttons on my razor view. Each row is a different set of radio buttons and I have given them each dynamic names.
I am new to MVC and i did not know how i can pass this radio button list to controller
this is my editor template
@model StudentManagement1.TeacherCourseStudent
@{
ViewBag.Title = "Attendance";
}
<tr>
<td>
@Model.Student_Id
</td>
<td>
@Model.Student.Name
</td>
<td>
@Model.Student.Sur_Name
</td>
<td>
@Model.Student.Semester.Semester_Name
</td>
<td>
@Html.RadioButton(@Model.Student_Id.ToString(), "present", true)
</td>
<td>
@Html.RadioButton(@Model.Student_Id.ToString(), "absent")
</td>
<td>
@Html.RadioButton(@Model.Student_Id.ToString(), "leave")
</td>
and this is my view
@model IEnumerable<StudentManagement1.TeacherCourseStudent>
@{
ViewBag.Title = "MarkAttendance";
Layout = "~/Views/Shared/_TeacherLayout.cshtml";
}
@using (Html.BeginForm("MarkAttendance", "Attendance", FormMethod.Post))
{
<table>
<tr>
<th>
Student Id
</th>
<th>
Name
</th>
<th>
Sur Name
</th>
<th>
Semester
</th>
<th>
Present
</th>
<th>
Absent
</th>
<th>
Leave
</th>
</tbody>
@Html.EditorForModel()
</table>
<br /> <br />
<input type="submit" value="Save attendance" />
}
here my controller to which i want to pass values
[HttpPost]
public ActionResult MarkAttendance(IEnumerable<string> Student_Id)
{
return view();
}
MVC
|
|
|
|
|
Hi,
I am designing a website. The designing is almost complete.
But I am noticing that there is many images and file is unlinked and in useful.
It is unnecessary present in the project. I would like to remove/delete it. But
it almost impossible to detect these types of files manually, impossible. So is there any way
to find these files ? Please help me.
|
|
|
|
|
I don't know of any tools to do it other than just manual. I suppose you could search google but since files can be referenced so many different ways, I doubt there is a tool that will work completely.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
That's where the expertise of the web designer comes into play.
I use a folder system for images, various folders that store different images, so it can be contained on a smaller scale.
for example
/images/cnc - contains all the theme and construction parts of the design.
/images/icons - contains all the small pieces of artwork
/images/adPanes - contains all the ad's
Many times, we place a image folder in the content folder, and when the content expires, we delete the whole folder.
/SpecialContent
/SpecialContent/images/image.jpg
/SpecialContent/scripts/js.js
/SpecialContent/index.html
It would be quite a task to organize your files and correct the links for them.
On the flip side, we don't delete many images, unless its a new project, in which we dump unused images before deployment.
|
|
|
|
|
Hello
I have a Project that Use Very Div Element And Onblur Event In its.
Because Of Security Reason We Switch From a version of JQuery To another .
But We Face With This Problem :
onblur Event dont Fire In Div Element
But it Fire in input elements Like Textbox!!!!!
and also onfocusout Event Fire in dive
but i dont want use this.
<div onblur="alert('dosent work this Event!!!!!')">
any help To solve this Problem can be useful
thanks in advance
|
|
|
|
|
Literally the first result on Google for "html div onblur":
For blur event to fire on an element, the element needs to receive focus first. But <div> elements do not receive focus by default.
You can add tabindex="0" or contentEditable to your div so it will receive focus.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
ok but focusout event fire without set tabIndex=0 to div element , and this means that div has focus in this scenario!!!!
i set "tabIndex=0" to div element for fire onblur and doesn't work!
|
|
|
|
|
The blur event fires when focus is lost. By default, a div element cannot have the focus in the first place so it can not be lost.
If you give the div a tabindex attribute, it will be able to accept focus:
<div id="divid" tabindex="0">Test content here</div>
then attach focus and blur event handlers:
document.getElementById("divid").onfocus = function() {
alert('focus is hit');
}
document.getElementById("divid").onblur = function() {
alert('blur is hit');
}
Hope this helps !!
Regards,
Praneet.
|
|
|
|
|
Hopefully, I am posting on correct forum.
I have a report with a parameter called loc.
The intended purpose of the report is to allow users to select a location from the dropdownlist and then records associated with that location are displayed to the users.
The dropdownlist is getting populated with values just fine.
However, when I select a location from the dropdownlist, I get an error that says:
Value cannot be null. Parameter name: reportParameters
Everything works fine when I pass a value as textbox but not as dropdown.
Any ideas what I am doing wrong?
Below are relevant code.
'---Dropdownlist control
<asp:Panel runat="server" ID="pnlLoc" Font-Names="Calibri" BorderStyle="Solid" BorderWidth="1" Style="margin: 0 auto; width:300px;">
<table>
<tr>
<td>
<asp:Label runat="server" ID="lblLoc" Text="Location: " />
</td>
<td>
<asp:DropDownList runat="server" ID="ddLoc" DataSourceID="dslocator6" AutoPostBack="True">
</asp:DropDownList>
</td>
</tr>
</table>
</asp:Panel
--Report viewer control
<rsweb:ReportViewer ID="ReportViewer1" runat="server" AsyncRendering="true" SizeToReportContent="true" Font-Names="Arial"
Height="675px" Width="750px">
<LocalReport EnableExternalImages="true" ReportPath="">
</LocalReport>
</rsweb:ReportViewer></center>
<asp:ObjectDataSource ID="LOC" runat="server" SelectMethod="GetData" TypeName="ManageReportsTableAdapters.searchBylocationsTableAdapter">
<SelectParameters>
<asp:ControlParameter ControlID="ddLoc" Name="Location" DefaultValue=" " />
</SelectParameters>
</asp:ObjectDataSource>
--This code populates the ddLoc dropdownlist
Protected Sub btnLoc_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnLoc.Click
ReportViewer1.LocalReport.ReportPath = ""
pnlLoc.Visible = True
which.Value = "P"
dslocator6.SelectCommand = "SELECT location FROM Locations ORDER BY [location]"
ddLoc.DataTextField = "location"
ddLoc.DataValueField = "location"
End Sub
Sub Run_Report(ByVal sel As String)
ReportViewer1.Reset()
ReportViewer1.LocalReport.DataSources.Clear()
Dim params(0) As ReportParameter
ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("locs", LOC.ID))
ReportViewer1.LocalReport.ReportPath = "locations.rdlc"
ReportViewer1.LocalReport.Refresh()
params(0) = New ReportParameter("loc", sel, False)
ReportViewer1.LocalReport.SetParameters(params) '<-- error points to this line
End Sub
I have been stuck on this for two days. Your assistance is greatly appreciated.
|
|
|
|
|
This means sel is null. If you debug you should find the issue.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
<asp:DropDownList runat="server" ID="ddLoc" DataSourceID="dslocator6" AutoPostBack="True">
</asp:DropDownList>
in your dropdownlist add listitems
<asp:listitem value="location">Location
|
|
|
|
|
Hi All, i'm after a bit of advice on the homepage of my app there is one particular section (Repeater) that queries the DB to provide a high level overview of the latest version of an application. Loading the data into this repeater is having an impact on the load time of the homepage so my thought on this is to is to add a checkbox to the page and on the initial page load do not populate the repeater but if the user checks the checkbox to display the data then go an query the DB to populate the repeater. Aside from only loading this data on request what other way could I control the populating of this repeater so that is not impacting performance?
|
|
|
|
|
i am beginner in asp.net so please recommend a book and articles please
|
|
|
|
|
|