ASP.NET
|
 |
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
Good day friends! Am having problem with my asp.net project. I have two buttons on the web page. One save to “Temp Files” and the other save to “UploadedImgs”. Saving to the “Temp Files” folder do not raise any exception but saving to the “UploadedImgs” folder causes an exception which says “Could not find a part of the path 'D:\ASP.Net Practical\Website\Site1\ UploadedImgs \'.” To me, the path is 100% correct. So please, does anyone has solution to this problem? Any help will be appreciated.
Below is the code am using.
Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim imgext As String = Path.GetExtension(FileUpload1.PostedFile.FileName) 'get image extension
Dim Imgname As String = Path.GetFileName(FileUpload1.PostedFile.FileName) 'get image name
Dim imgpath As String = "\ASP.Net Practical\Website\Site1\ UploadedImgs \" 'get local disk folder path
FileUpload1.PostedFile.SaveAs(Server.MapPath(imgpath + Imgname + imgext))
End Sub
|
|
|
|
 |
Clean the save filename first, remove or strip invalid chars, then build the path based on a virtual path, not a physical path. The path will then be converted to a physical path with the Drive letter and all.
Dim fileName as String = Clean_FileName(avatarName.ToLower() + oFileExt)
Dim path as string = Path.Combine(Server.MapPath("~/Images/avatars/customers"), fileName)
Public Shared Function Clean_FileName(ByVal strIn As String) As String
' Replace invalid characters with empty strings.
Try
Return Regex.Replace(strIn, "[^\w.@-_]", "", RegexOptions.None, TimeSpan.FromSeconds(1.5))
Catch As RegexMatchTimeoutException
Return String.Empty
End Try
End Function
|
|
|
|
 |
Solved: Thanks. I found the solution after so many trials. I think I should share this so that anyone with such problem could resolve it with ease. The problems was from my webpage submitting an empty filename because of the page load event. So, the solution to this problem is ensure that the uploaded filename is intact before calling the SaveAs command.
Once again, thanks for your reply.
Cheers!
|
|
|
|
 |
Well yes that's a good idea.
But the way your mapping out the path may backfire on you when you publish your web app for production use.
Uploading files of anything requires good knowledge of how it works. There about 5 ways to do it to my knowledge.
I don't use the file name of the file anymore, for now I assign my own name to the file. Later on down the road, as users keep uploading the same file with different names, you will have gigs of files sitting in the folder, and the project size will radically expand in size over the course of time. Then what? That's another topic for discussion.
|
|
|
|
 |
Anybody please suggest how to set the DataTable Width in dot net.
|
|
|
|
 |
What DataTable are you talking about? Have you checked the documentation for class properties?
|
|
|
|
 |
DataTable does not have a width, DataTable Properties (System.Data)[^], since it does not have a UI component.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
 |
Hi All,
I am writing my AngularJS - js file as below and using ng-repeat as well as below, but when I add or remove item into the list angularJS is not refreshing it automatically on View, am I missing something, it is happening on IE but on Chrome its refreshing the list automatically. Am I missing something or do I need to explicitly refresh the list etc to show the most updated list on IE, I have to use only IE at my work - please any help is appreciated thank you.
Here is my View
<body>
<div data-ng-app="myApp" data-ng-controller="userController">
<table style="border:none 0px gray;">
<tr>
<td>
<table style="border:solid 1px gray;">
<tr>
<td style="border:solid 1px gray;">User Id</td>
<td style="border:solid 1px gray;">User Name</td>
</tr>
<tr data-ng-repeat="usr in users">
<td><a href="/User/UpdateUser/{{usr.UserId}}"> {{usr.UserId}} </a> </td>
<td><a href="/User/UpdateUser/{{usr.UserId}}">{{usr.UserName}}</a></td>
</tr>
</table>
<pre>
</td>
<td>
<a href="http://www.codeproject.com/Members/html">@Html</a>.ActionLink("Create User", "CreateUser")
</td>
</tr>
</table>
</body>
And here is my script
var myApp = angular.module('myApp', []);
myApp.controller('userController', ['$scope', '$http', function ($scope, $http) {
$scope.users = "";
$http.get("/User/GetUsers")
.success(function (result) {
$scope.users = result;
})
.error(function (result) {
console.log(result);
});
}]);
Here is my Controller Action method, when an item is added to the list, it will call the Idex method which calls this AngularJS function but some how the function is not getting called and the update on the View is not showing up, please help me.
public ActionResult CreateUser()
{
return View();
}
[HttpPost]
public ActionResult CreateUser(FormCollection collection)
{
try
{
string Id = Request.Form["UserId"];
string UserName = Request.Form["UserName"];
int UserId;
var dbContext = new MVCDBContext();
User user = new User();
user.UserId = (int.TryParse(Id, out UserId) ? UserId : 0);
user.UserName = UserName;
dbContext.Users.Add(user);
dbContext.SaveChanges();
return RedirectToAction("Index");
}
catch
{
return View();
}
}
Thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
modified 3 days ago.
|
|
|
|
|
 |
|
General
News
Suggestion
Question
Bug
Answer
Joke
Praise
Rant
Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.