|
|
If you read the comments to that answer, you'll see that it's retrieving the server's MAC address. As are almost all the other answers on that thread.
If the client is not on the same subnet as the server, there is no way to retrieve the MAC address of the client from the server. There have occasionally been hacks which exploited security vulnerabilities on the client to allow you to retrieve it, but those are fixed almost as soon as they're found.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Please help me... I am stuck up with http post using http request.
I have an asp.net applicaton which is hosted locally in IIS(http:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Test Web Page</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript">
function showImage() {
alert('hi');
}
</script>
</head>
<body>
<form id="imageForm" name="imageForm" method="post" action="Default.aspx" >
<input type="text" name="showImage" value="false" />
<input type="submit" name="refresh" value="submit" onclick="showImage();" />
</form>
</body>
</html>
My Default.aspx.cs ;
protected void Page_Load(Object Source, EventArgs E)
{
}
I have a separate c# application which tries to simulate the button click of "refresh" via http post to Default.aspx, here is the code;
string url = "http://localhost/TestWebPage/Default.aspx";
string postDataStr = "showImage=true";
postDataStr += "&refresh=submit";
byte[] postData = Encoding.ASCII.GetBytes(postDataStr);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = postData.Length;
req.Proxy = WebRequest.DefaultWebProxy;
using (var reqStream = req.GetRequestStream())
{
reqStream.Write(postData, 0, postData.Length);
}
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream, Encoding.Default);
string pageContent = reader.ReadToEnd();
string status = ((HttpWebResponse)response).StatusDescription;
reader.Close();
responseStream.Close();
response.Close();
My aspx page is already opened in a chrome browser. When the above code is executed, I want the javascript alert in the showImage() function to be displayed in the Default.aspx page in the same browser window itself.
Unfortunately its not happening now... am I missing anything? or is there any good approach to simulate the button click using separate c#?
Please guide.
|
|
|
|
|
You already posted this in the C# forum. Please post in one place only.
|
|
|
|
|
Hi,am developing an asp.net in vs2008 and want to successfully get the jQury library running within vs8.
Through googling,I have come to realize that I need to download and install a hotfix for vs8 called KB946581. I have however tirelessly tried to find where to download this fix but failed. Can someone please give a legitimate source? My efforts so far are as follows:
<script type = "text/javascript" src="/jQuery/jquery-1.7.1.min.js"></script>
<script src="/jQuery/jquery-1.7.1.min-vsdoc.js" type="text/javascript"></script>
<script type = "text/javascript" src="/jQuery/jquery.nivo.slider.pack.js"></script>
I plan on using the Nivo slider plugin to effect some image animations on my home page.
Hope some can give a better reliable outlay of how to get jQuery runing in vs2008.
|
|
|
|
|
What's wrong with what you have? Getting jQuery working is just a matter of including the right js file as you are doing. Make sure the path is valid, however you should use something like Page.ResolveUrl for webforms or Url.Content for MVC to turn a virtual path (~/jQuery/...) into a working path.
|
|
|
|
|
Hi,I succeeded in getting jQuery 1.2.6 library running in visual studio 2008.Thanks for the guide.However when I try using library version 1.7.1 it does not work.Could there be another special hotfix for vs8 prof. edition to support this library version or what could I be missing??
In my trials testing I noticed that;
This works perfect:
<script type = "text/javascript" src="<%:ResolveUrl("~/scripts/jquery-1.2.6.js")%>"></script>
<script type ="text/javascript" src="<%: ResolveUrl("~/scripts/jquery-1.2.6-vsdoc.js")%>"></script>
But when I try this below -- It fails...why???
<script type = "text/javascript" src="<%:ResolveUrl("~/scripts/jquery-1.7.1.js")%>"></script>
<script type ="text/javascript" src="<%: ResolveUrl("~/scripts/jquery-1.7.1-vsdoc.js")%>"></script>
Please highlight explicitly....
|
|
|
|
|
What do you mean by "fails"?
Is it not loading the script? If so, check that you've got the correct path and filename.
Is it generating a client-side error? If so, you'll need to give us the details of the error, and tell us which browser you're using.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Okay,once I have referenced the js scripts,then try check if there is any intellisense using the jquery selector $(),I get nothing however with version 1.2.6 of the library,it shows intellisense.
I have no client side script errors so far. Am using
Google chrome Version 59.0.3071.86 .
|
|
|
|
|
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.
|
|
|
|