|
So it's not that jQuery isn't working; it's just that you're not getting intellisense?
Try this article: How to fix Visual Studio 2008 Intellisense for JQuery 1.6.1[^] - it says 1.6.1, but it probably applies to 1.7 as well.
If it still doesn't work, then you'll either need to upgrade to a more recent version of Visual Studio, or fall back to using the jQuery documentation[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
code taken from this area https://www.codeproject.com/Articles/1005485/RESTful-Day-sharp-Security-in-Web-APIs-Basic#_Toc423441907
[GET("allproducts")]
[GET("all")]
public HttpResponseMessage Get()
{
}
[GET("productid/{id?}")]
[GET("particularproduct/{id?}")]
[GET("myproduct/{id:range(1, 3)}")]
public HttpResponseMessage Get(int id)
{
}
[POST("Create")]
[POST("Register")]
public int Post([FromBody] ProductEntity productEntity)
{
}
[PUT("Update/productid/{id}")]
[PUT("Modify/productid/{id}")]
public bool Put(int id, [FromBody] ProductEntity productEntity)
{
}
[DELETE("remove/productid/{id}")]
[DELETE("clear/productid/{id}")]
[PUT("delete/productid/{id}")]
public bool Delete(int id)
{
}
1) in what kind of scenario people use multiple http verbs for single action because it create multiple route for single action which may confuse people.......should the the below approach is good or not ?
[GET("productid/{id?}")]
[GET("particularproduct/{id?}")]
[GET("myproduct/{id:range(1, 3)}")]
public HttpResponseMessage Get(int id)
{}
2)PUT and DELETE is different verbs. how one can use different verbs for single action....is it right approach.
[DELETE("remove/productid/{id}")]
[DELETE("clear/productid/{id}")]
[PUT("delete/productid/{id}")]
public bool Delete(int id)
{
if (id > 0)
return _productServices.DeleteProduct(id);
return false;
}
the person who wrote this article he is codeproject MVP it means he has good command over technology then how he can follow a wrong approach ?
any idea?
please discuss in details. thanks
|
|
|
|
|
Please post your question in the forum at the end of the article.
|
|
|
|
|
Rathan than thinking that multiple urls are used to call the same method, think of it that multiple API methods can all be served by the same function. So there are various REST methods you can use that will result in a product being deleted, so those various methods may as well be handled by the same code method.
However I don't think the GET example is a particularly good way of doing things. If I want to get a product using REST I'll call Product/id. Being able to use that url or "particularproduct" doesn't seem to be adding any value, just having two urls that do the same thing.
As suggested though ask your question on the article, this is just my personal opinion and the author may well have a good answer that renders my opinion invalid.
|
|
|
|
|
yes i did it but the author "akhil mittal" did not answer still.
|
|
|
|
|
i am learning web api. just gone through few article and found attribute routing can be done different way. i visited these articles
https://www.codeproject.com/Articles/774807/Attribute-Routing-in-ASP-NET-MVC-WebAPI http://www.c-sharpcorner.com/UploadFile/b1df45/web-api-route-and-route-prefix-part-2/ https://www.codeproject.com/Articles/999691/RESTful-Day-sharp-Custom-URL-Re-Writing-Routing-us
[RoutePrefix("Movie")]
public class HomeController : Controller
{
[Route]
public ActionResult Index()
{
ViewBag.Message = "You are in Home Index";
return View();
}
[Route("~/NewRoute/About")]
public ActionResult About()
{
ViewBag.Message = "You successfully reached NEWRoute/About route";
return View();
}
}
in above example the author use Route attribute to define route for action.
see this one again
[GET("productid/{id?}")]
public HttpResponseMessage Get(int id)
{
var product = _productServices.GetProductById(id);
if (product != null)
return Request.CreateResponse(HttpStatusCode.OK, product);
return Request.CreateErrorResponse(HttpStatusCode.NotFound, "No product found for this id");
}
here author do not use route attribute rather use http verbs to define route.
so tell me which approach is right ?
another question that by attribute routine we can give different name to action then when one should use action name attribute to give different name to action?
when we can change action name by attribute routing then why should one use action name attribute to give different name to action?
please clarify my two points. thanks
|
|
|
|
|
hi all.
I add in a loop many user controls and i see them on screen, but when a click is performed in one of them, all of the fires the click event.
I'm new in asp.net, so if you see coding horrors be nice.
Thanks
here i add the controls
protected void Page_Load(object sender, EventArgs e)
{
AddProgressBarForPN(3, "rev123", "pndesc123", "pn123");
AddProgressBarForPN(2, "rev12", "pndesc12", "pn12");
AddProgressBarForPN(1, "rev1", "pndesc1", "pn1");
}
void prog_ProgressBarBttnClicked(string stempID,string pn)
{
support.Logs(stempID +" "+pn, "prog_ProgressBarBttnClicked", false);
}
protected void cloneBttn_Click(object sender, EventArgs e)
{
}
private void AddProgressBarForPN(int step,string rev,string pn_desc,string pn)
{
prog = (ProgressBarControl)LoadControl("~/ProgressBarControl.ascx");
prog.ProgressBarBttnClicked += prog_ProgressBarBttnClicked;
prog.Step = step;
prog.Revision = rev;
prog.PN_Description = pn_desc;
prog.ClientName = pn_desc;
prog.PN = pn;
HtmlTableRow row = new HtmlTableRow();
HtmlTableCell cell1 = new HtmlTableCell();
cell1.Controls.Add(prog);
row.Cells.Add(cell1);
mainTable.Rows.Add(row);
and this is the control html
var idd;
function getID(oObject) {
idd = oObject.id;
var hdnfldVariable = document.getElementById('hdnfldVariable');
__doPostBack(idd);
}
table, th, td
{
color:darkblue;
margin-top:-15px;
}
<asp:hiddenfield id="hdnfldVariable" runat="server">
<asp:table style="width:100%;margin-top:15px" id="mainTable" runat="server">
<asp:tablerow>
<asp:tablecell>
PN: | <%=this.PN %> | / | Client: | <%=this.ClientName %> | / | Description: | <%=this.PN_Description %> | / | Rev: | <%=this.Revision %> |
<%-- onclick="StepClicked(this)"--%>
1
Collect files
2
Software preparation
3
Debug
4
Validation
5
Release
and control code behind
public delegate void ProgreesBarButton(string stepID,string PN);
public event ProgreesBarButton ProgressBarBttnClicked = delegate { };
protected void Page_Load(object sender, EventArgs e)
{
Page.ClientScript.GetPostBackEventReference(this, string.Empty);
var arg = Request.Form["__EVENTTARGET"];
if(arg != null)
{
string progBttnID = arg.ToString();
ProgressBarBttnClicked(progBttnID,PN);
}
}
public string ClientName{ get; set; }
public string PN_Description{ get; set; }
public string PN{ get; set; }
public string Revision{ get; set; }
public string step1 { get; set; }
public string step2 { get; set; }
public string step3 { get; set; }
public string step4 { get; set; }
public string step5 { get; set; }
int step;
public int Step
{
get { return step;}
set
{
step = value;
for (int i = 1; i <= step; i++)
{
switch (i)
{
case 1:
step1 = "active";
break;
case 2:
step2 = "active";
break;
case 3:
step3 = "active";
break;
case 4:
step4 = "active";
break;
case 5:
step5 = "active";
break;
}
}
for (int i = step+1; i <= 5; i++)
{ switch (i)
{
case 1:
step1 = "";
break;
case 2:
step2 = "";
break;
case 3:
step3 = "";
break;
case 4:
step4 = "";
break;
case 5:
step5 = "";
break;
}
}
}
}
public void StepClicked(string stepid)
{
ProgressBarBttnClicked(stepid, PN);
}
modified 8-Jun-17 9:09am.
|
|
|
|
|
i want to know how to move a next textbox when user click on enter key.
|
|
|
|
|
Move how? You can change the layout properties, such as the Left Right and other settings, add paddings, change the margins as needed.
Also, apart from the Web Forms code, you can do that in JavaScript code as well, handling the events of key, and then changing the CSS properties of the elements. Something like this,
$("txtBx").keyup(function (event) {
if(event.which == 13) {
var otherTxtBx = $("otherTxtBx");
otherTxtBx.css("margin", "25px");
}
});
This was obviously a thousand-feet overview, but since you have not shown any attempt, I believe this will help you out.
.keyup() | jQuery API Documentation
Did you mean to focus on another text box?
If that is the case, then you can change the code in the condition, to the following one,
otherTxtBx.focus();
That would do the trick, also if the requirement is something else (other than these two) you can implement that in the condition block, so that it gets executed when user presses enter key.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
modified 8-Jun-17 11:48am.
|
|
|
|
|
I think user actually means to move the cursor to a text box. Not actually move the text box, although it does sound that way.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Right, might have been. I updated my answer nonetheless. Thank you for reminder.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
+5
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
yes move cursor on click to next texbox
|
|
|
|
|
Hi,
I bind a detailsview/grid, etc. via ODS to an EF-object, maybe a SQL-Query with calculated fields, unions, unpivot, etc. To this source i can't do an update with db.Savechanges(), i have to update the orign table. I tried, but maybe i used different context. I used the same but no success. No error at SaveChanges to the orign table, but the changed data is not in the SQL-DB. Maybe because of the binding?
How can i select from ODS and update to EF-Object?
Thanks for help!
|
|
|
|
|
|
Thanks, but something like this would work, too:
db.ObjectStateManager.ChangeObjectState(Item, EntityState.Modified);
And work with the same context, or use attach/detach.
|
|
|
|
|
|
C# code
protected void Page_Load(object sender, EventArgs e)
{
string markers = GetMarkers();
string map = @"
<script type='text/javascript' src='http://maps.googleapis.com/maps/api/js?sensor=false&key=keyvalue'></script>
<script type='text/javascript'>
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(28.3213, 77.5435),
zoom: 2,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var myMap = new google.maps.Map(document.getElementById('mapArea'),
mapOptions);" + markers + @"}
</script>
";
Page.ClientScript.RegisterStartupScript(this.GetType(), "initialize", map, false);
}
protected string GetMarkers()
{
string markers = "";
SqlConnection conn = new SqlConnection();
conn.ConnectionString =ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
{
SqlCommand cmd = new SqlCommand("SELECT Latitude, Longitude, RegistrationNumber FROM DriverLocation", conn);
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
int i = 0;
while (reader.Read())
{
i++;
markers +=
@"var marker" + i.ToString() + @" = new google.maps.Marker({
position: new google.maps.LatLng(" + reader["Latitude"].ToString() + ", " +
reader["Longitude"].ToString() + ")," +
@"map: myMap,
title:'" + reader["RegistrationNumber"].ToString() + "'});";
}
}
return markers;
}
}
html code
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div id="mapArea" style="width: 500px; height: 500px;">
</div>
</form>
</body>
</html>
|
|
|
|
|
You never call your initialize function. You should pass it as the callback parameter to the maps API script:
string map = @"
<script type='text/javascript' src='http://maps.googleapis.com/maps/api/js?key=keyvalue&callback=initialize'></script>
..."
Getting Started | Google Maps JavaScript API | Google Developers[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
I would like to have a Base Model and use it in my _Shared view. I followed some examples online and did the following but I was unable to make it work:
_Layout view:
@model Portal.Models.BaseViewModel
Hi, @Model.FirstName
Base Model:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Portal.Models
{
public class BaseViewModel
{
public String FirstName { get; set; }
}
}
Base Controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Portal.Models;
namespace Portal.Controllers
{
public class BaseController : Controller
{
public BaseController()
{
BaseViewModel baseModel = new BaseViewModel()
{
FirstName = "John"
};
}
}
}
Dashboard Controller:
public class DashboardController : BaseController
When I run the application, I get the following error for @Model.FirstName:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
Am I missing something?
Thank you for your time and consideration.
|
|
|
|
|
It's probably because -
1. you do not have constructor for BaseViewModel to assign any default value to FirstName(which you can access if no other value assigned to it), you have just declared the property for get and set.
2. In any of BaseController or DashboardController you do not have property which hold data for BaseViewModel. On BaseController you have created it but not assigned to anything.
Try something like below and then access "BaseController.baseModel" to pull value of FirstName
public class BaseController : Controller
{
BaseViewModel baseModel;
public BaseController()
{
baseModel = new BaseViewModel()
{
FirstName = "John"
};
}
}
modified 20-Sep-20 21:01pm.
|
|
|
|
|
Thank you for your help
modified 3-Jun-17 11:56am.
|
|
|
|
|
codeproject registration page show a dropdown which show client timezone and client can change it during registration. so i like to know how codeproject registration page knows what is client timezone at their server end because we know that from server end we can not detect client timezone. only at client side we can detect client's timezone by javascript.
so please any codeproject moderator tell me how they show client timezone selected in their dropdown in registration page. just give me some idea.
|
|
|
|
|
|
thanks great
|
|
|
|
|