|
Thank-you very much Richard Deeming , Your comment was very helpfull
|
|
|
|
|
Hello.
I am trying to build an event calendar using ASP.net for my organization. The article I used for reference is AJAX Event Calendar (Scheduler) for ASP.NET MVC in 80 Lines of Code[^]
I have followed the instructions to the letter but I keep getting an error:
Error 1 The type or namespace name 'Event' could not be found (are you missing a using directive or an assembly reference?
What am I doing wrong?
Here are the code blocks of my application:
1)Index
@{ ViewBag.Title = "AJAX Monthly Event Calendar for ASP.NET MVC"; }
<h2>ADE R and T Event Calendar</h2>
<script src="@Url.Content("~/Scripts/DayPilot/daypilot-all.min.js")" type="text/javascript"></script>
@Html.DayPilotMonth("dp", new DayPilotMonthConfig
{
BackendUrl = Url.Content("~/Home/Backend"),
EventMoveHandling = DayPilot.Web.Mvc.Events.Month.EventMoveHandlingType.CallBack,
EventResizeHandling = DayPilot.Web.Mvc.Events.Month.EventResizeHandlingType.CallBack,
TimeRangeSelectedHandling = DayPilot.Web.Mvc.Events.Month.TimeRangeSelectedHandlingType.JavaScript,
TimeRangeSelectedJavaScript = "dp.timeRangeSelectedCallBack(start, end, { name: prompt('New Event Name:', 'New Event') });"
})
2) HomeController.CS
using System;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DayPilot.Web.Mvc;
using DayPilot.Web.Mvc.Events.Month;
namespace Calendar1.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult Backend()
{
return new Dpm().CallBack(this);
}
class Dpm : DayPilotMonth
{
protected override void OnInit(InitArgs e)
{
var dbo = new DataClasses1DataContext();
Events = from ev in dbo.events select ev;
DataIdField = "EventID";
DataTextField = "EventText";
DataStartField = "EventStart";
DataEndField = "EventEnd";
Update();
}
protected override void OnEventMove(EventMoveArgs e)
{
var dbo = new DataClasses1DataContext();
Events = from ev in dbo.events select ev;
var toBeResized = (from ev in dbo.events where ev.EventID == Convert.ToInt32(e.Id) select ev).First();
toBeResized.EventStart = e.NewStart;
toBeResized.EventEnd = e.NewEnd;
dbo.SubmitChanges();
Update();
}
protected override void OnEventResize(EventResizeArgs e)
{
var dbo = new DataClasses1DataContext();
Events = from ev in dbo.events select ev;
var toBeResized = (from ev in dbo.events where ev.EventID == Convert.ToInt32(e.Id) select ev).First();
toBeResized.EventStart = e.NewStart;
toBeResized.EventEnd = e.NewEnd;
dbo.SubmitChanges();
Update();
}
protected override void OnTimeRangeSelected(TimeRangeSelectedArgs e)
{
var dbo = new DataClasses1DataContext();
Events = from ev in dbo.events select ev;
var toBeCreated = new Event { EventStart = e.Start, EventEnd = e.End, text = (string)e.Data["name"] };
dbo.events.InsertOnSubmit(toBeCreated);
dbo.SubmitChanges();
Update();
}
public object toBeCreated { get; set; }
}
}
}
3) Web.config
="1.0"
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="DayPilot.Web.Mvc"/>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
<add namespace="Calendar1" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.webServer>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
I am using Visual Studio 2013. Are there any changes I need to make to the code? Most of it I copy-pasted from the article used for reference.
I apologize if the question is too long. Thanks in advance!
Please let me know what I am doin
|
|
|
|
|
i hard the term Katna but do not know what it it & what it's usage in .net ? so please some one briefly discuss what is it and when one should use it and also advantages too. please do not redirect me to www.asp.net web site
thanks
tbhattacharjee
|
|
|
|
|
|
|
OWIN ( initials for Open Web Interface for .NET )is a set of specifications that defines a stardand interface between which .NET web servers and web applications communicates. Katana on the hand is an implementation of the OWIN.
Praveen
|
|
|
|
|
Hi,
I have a web service.
In certain scenarios, I want to send specific status Codes back to the client.
I tried using the context.Response.statusCode but it doesn't work.
Anyone knows how can I accomplish that?
|
|
|
|
|
Always include the relevant code in your question.
ThetaClear wrote: I tried using the context.Response.statusCode but it doesn't work. how? you got any error? debug it. Update your question with error details.
|
|
|
|
|
I just wrote something like that:
Context.Response.StatusCode = 422;
and expected to get 422 on the client but I got 200
|
|
|
|
|
|
I went through this article.
The writer says that he used an httpModule to change the header status code.
He also wrote that he could do that just by changing the statusCode in the .aspx page itself (which I did but with no luck)
Is there some kind of a restriction from changing the statusCode in my web service?
|
|
|
|
|
It works now.
It was something stupid that I didn't pay attention to.
The Response.StatusCode = number; does work.
|
|
|
|
|
Well if your input is JSON
then you just send back JSON with a status code
If it's XML, then you send back XML with a status code field
So on my web applications that access a web service in JSON, I always send back a JSON formatted status code to let the Jquery or JavaScript know the final result.
|
|
|
|
|
hi everyone, i have been trying to create reports at runtime using crystal reports and vb.net, i want the user to select the fields/columns he wants to view in the report and choose as many fields as he wants.i have been searching for such but got no straight forwad answer. can anyone kindly help with such a solution
|
|
|
|
|
|
Firstlly you should create a formula field for showing the data into the report.
then drop that particular field on ther report section
after that you can pass the parameter like This :
string FromMonth = Convert.ToString(ddlYear.SelectedDate.Value.ToShortDateString() + " " + "To" + " " + ddlToYear.SelectedDate.Value.ToShortDateString());
ReportDocument rptDoc = new ReportDocument();
rptDoc.Load(Server.MapPath("");
rptDoc.SetDataSource(dsReport);
rptDoc.DataDefinition.FormulaFields["FromYear"].Text = "'" + FromMonth + "'";
CrystalReportViewer1.ReportSource = rptDoc;
CrystalReportViewer1.DataBind();
|
|
|
|
|
Hi.
I have an application consists of 2 textboxes, 2 buttons, a modalpopup extender.
Button1 and Textbox1 is in a modalpopupextender that is shown when a button is click (not shown here)
I added an OnKeyPress event on my textbox (Textbox1) on Page Load that will execute a javascript on client side code which calls a button (Button1) click event.]
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.TextBox1.Attributes.Add("onKeyPress", "doClick('" + Button1.ClientID + "',event)");
}
}
This is the Javascript codes, this will call and execute the click event of Button1
function doClick(buttonName, e) {
var key;
if (window.event)
key = window.event.keyCode;
else
key = e.which;
if (key == 13) {
var btn = document.getElementById(buttonName);
if (btn != null) {
btn.click();
event.keyCode = 0
}
}
};
This is the Button1 Click event
protected void Button1_Click(object sender, EventArgs e)
{
if (Textbox1.Text.ToString() == "ITDevt")
{
Button2.Visible = true;
Textbox2.Visible = false;
Button2.Visible=true;
Button1.Visible=false;
popup.Show();
}
else
{
popup.Hide();
Textbox1.Text = "";
}
}
Assume that the modalpopupextender is shown, so I entered a text in Textbox1 and presses Enter key on keyboard (so the OnKeyPress event is rendered).
When I trace the Button1_Click event, the code block runs. But the popup (modalpopupextender) hides.
Can you help me show again the modalpopupextender and hide Button1 and Textbox1 then show Button2 and Textbox2?
|
|
|
|
|
Hello , I need to copy the structure of a gridview programatically to an another new grid view , is that even possible ?
|
|
|
|
|
Possibly you're talking about this[^]
|
|
|
|
|
Hello !
I am building a MVC 5 app in which there will be 4 types of users . (Admin , HR Member , Managers , Employee) . I already created the views and the controllers for each type .
I want to give each manager access to certain departments , and the employee access to data according to his employeeID value .
After reading several articles on the Internet about this topic , I suppose I have to assign each user type a role and each department/employeeID a permission , but I have no clue on how to do that .
Can someone explain to me how to implement this ? I mention that the Identity Framework installed on the project is at version 1.0 .
|
|
|
|
|
You need to create Roles & Permissions. You need to create a table (like "Roles") that store the Roles
In your app there is 4 Roles
1- Admin
2- HR Member
3- Managers
4- Employee
And need to store all the permissions in a Table (like "Permission" table).
for each Role you need to map the permissions means to specify what are the permission available for Admin, HR Member, Managers & Employee. To do this you need to create a table (like RolesPermission) that contains the Id of Role and also the Ids of Permission that "One To Many" mapping. like
ID RoleId PermissionId
1 1 1
2 1 2
3 1 4
4 2 4
5 2 5
... ... ...
After that you just need to assign the Role to the users. And where the user can access resources or not You just need to get Permissions of that user and check the permission that available to access the resources. If available then give access otherwise don't give access.
|
|
|
|
|
Ok , in other words I should have three classes :
Role
Permission
RolePermission(in which I should include two objects , one of type Role , and one of type Permission)
And I should link the RolePermission to the ApplicationUser , then apply the migration .
Is that correct ?
|
|
|
|
|
Yes
|
|
|
|
|
Ok , I got stuck again .
So I created the classes :
Role :
public class Role
{
public Role() { }
public Role(string name, int id):this()
{
this.RoleId = id;
this.Name = name;
}
[Key]
[Required]
public virtual int RoleId { get; set; }
public virtual string Name { get; set; }
}
Permission :
public Permission()
{ }
public Permission(string name,int id):this()
{
this.Name=name;
this.Id = id;
}
[Key]
[Required]
public virtual int Id { get; set; }
public virtual string Name { get; set; }
}
RolePermission :
public class RolePermission
{
public Role Role { get; set; }
public Permission Group { get; set; }
[Required]
public int RoleGroupId { get; set; }
public RolePermission() { }
}
I updated the ApplicationUser class
public class ApplicationUser : IdentityUser
{
public ApplicationUser()
: base()
{
this.Permission=new HashSet<RolePermission>();
}
[Required]
public string Name { get; set; }
public virtual ICollection<RolePermission> Permission { get; set; }
}
Is this correct up to this point ?
I suppose I should modify the ApplicationDbContext , which , up to this point , looks like this :
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection")
{
}
}
What changes should I do ?
|
|
|
|
|
Yes you are right. You should use this one
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection")
{
}
}
|
|
|
|