|
Oh really I'm pu**y are you human? Be a human first before becoming anything, I guess you're born to human parents at least.
Is no one seeing this? Why are your hands tied up to flag this message?
modified 23-Jan-19 23:29pm.
|
|
|
|
|
Quote: Thanks Rick, it has been resolved my friend.
This was the message I replied to Richard, what is there in this message that can catch me as spammer? I am not able to understand?
|
|
|
|
|
Go to the Bug&Suggestions forum and ask the admins, if you want.
For me, this topic is ended.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
In a vb.net 2010 web form application that uses web form controls, there is a 'process' button where the user can click on the button lots of times.
This causes problems in the application for every time the button is clicked on, that many records are created in the sql server 2016 database.
I would like a solution on how to prevent the user from clicking on the button more than one time. I have a 'click button' code to catch when the button is clixked right away.
But I would like to know what I can do so the user knows they cannot click the button more than once:
1. I could make the button invisible.
2. However I would either like to have a popup message and/or somewhere on the webpage saying they can click on the process button only one time.
Thus can you show me the code on preferable setting up a popup menu? If not, can you show me the code on how to display the message on the web form page?
|
|
|
|
|
|
give me better suggetions
|
|
|
|
|
Make a .CS file with name of ImportExcel.CS
:----
public class FileExt : ValidationAttribute
{
public string Allow;
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
if (value != null)
{
string extension = ((System.Web.HttpPostedFileBase)value).FileName.Split('.')[1];
if (Allow.Contains(extension))
return ValidationResult.Success;
else
return new ValidationResult(ErrorMessage);
}
else
return ValidationResult.Success;
}
}
public class ImportExcel
{
[Required(ErrorMessage = "Please select file")]
[FileExt(Allow = ".xls,.xlsx", ErrorMessage = "Only excel file")]
public HttpPostedFileBase file { get; set; }
}
And Add this code to your controller
:-----
public ActionResult ImportExcel()
{
return View();
}
[HttpPost]
public ActionResult importexcel(ImportExcel importExcel)
{
if (ModelState.IsValid)
{
string path = Server.MapPath("~/library/ExcelFile/" + importExcel.file.FileName);
importExcel.file.SaveAs(path);
string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0; Data Source='" + path + "';Extended Properties='Excel 12.0;'";
OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
excelConnection.Open();
string tableName = excelConnection.GetSchema("Tables").Rows[0]["TABLE_NAME"].ToString();
excelConnection.Close();
OleDbCommand cmd = new OleDbCommand("Select * from [" + tableName + "]", excelConnection);
excelConnection.Open();
OleDbDataReader dReader;
dReader = cmd.ExecuteReader();
SqlBulkCopy sqlBulk = new SqlBulkCopy(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
sqlBulk.DestinationTableName = "ExcelFile";
sqlBulk.ColumnMappings.Add("Userid", "Userid");
sqlBulk.ColumnMappings.Add("Name", "Name");
sqlBulk.ColumnMappings.Add("TelephoneNo", "TelephoneNo");
sqlBulk.ColumnMappings.Add("Address", "Address");
sqlBulk.ColumnMappings.Add("EmailAddress", "EmailAddress");
sqlBulk.WriteToServer(dReader);
excelConnection.Close();
ViewBag.Result = "Successfully Imported";
}
return View();
}
And create view page of ImportExcel method with name of ImportExcel.cshtml and add this code
:-----
@model Models.GeneralModel.ImportExcel
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>ImportExcel</title>
</head>
<body>
<div style="float:right">
<h4>@ViewBag.Result</h4>
@using (Html.BeginForm("ImportExcel", "NewCustomer", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.TextBoxFor(m => m.file, new { type = "file" })
<button id="submitButton" type="submit">Submit</button>
@Html.ValidationMessageFor(model => model.file)
}
</div>
</body>
</html>
|
|
|
|
|
You do realise we can all see you talking to yourself, don't you?
Quote:
string extension = ((System.Web.HttpPostedFileBase)value).FileName.Split('.')[1];
Lots of problems with that line. For example, what if the uploaded file doesn't contain an extension? What if it contains multiple "." characters? What if the extension is .lsx ? Etc.
Try:
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
var file = value as System.Web.HttpPostedFileBase;
if (file != null)
{
string extension = System.IO.Path.GetExtension(file.FileName);
string[] allowedExtensions = Allow.Split(',');
if (!Array.Exists(allowedExtensions, ext => string.Equals(ext, extension, StringComparison.OrdinalIgnoreCase)))
{
return new ValidationResult(ErrorMessage);
}
}
return ValidationResult.Success;
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
i have been trying to get my program to start but it keeps refusing to.can anyone help me find a solution to the error below.thanks
This site can’t be reached localhost refused to connect.
Search Google for localhost 58962
ERR_CONNECTION_REFUSED
|
|
|
|
|
You're trying to access a web server running on port 58962 of your local machine, but there is on web server running there. We can't access your machine so we can't tell you why that is. Typically you only use non-standard ports when running the site in debug mode from Visual Studio. So either you are trying to access your site outside of VS, or VS's internal web server isn't working for some reason.
|
|
|
|
|
I am new to ASP.NET MVC, getting error at below code :
<div id="wrapper" style="background-color:#fff;">
<nav class="navbar navbar-default navbar-cls-top " role="navigation" style="margin-bottom: 0">
<div class="navbar-header">
<a class="navbar-brand" href="/Home/EmployeeDashboard" target="_blank">
@{
string comnameup = "";
using (PMEntities dc = new PMEntities())
{
var data = dc.tblGenerals.SingleOrDefault();
comnameup = data.CompanyName;
@comnameup
}
}
</a>
</div>
also adding connection string :
<connectionStrings>
<add name="PMEntities" connectionString="metadata=res://*/PMData.csdl|res://*/PMData.ssdl|res://*/PMData.msl;provider=System.Data.SqlClient;provider connection string="data source=localhost\SQLEXPRESS;initial catalog=eee;integrated security=SSPI;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
|
|
|
|
|
You need to look at the full details of the exception, including the InnerException , to see what the error is.
NB: SingleOrDefault will return null if there are no records. When you try to read the property on the next line, you could potentially get a NullReferenceException . It would be better to use Single in this instance.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Is anyone help me out for import tables data from PDF file and show them on front using C#,.Net ,please suggest me a piece of code for random column and row and also recommend library OR 3RD party such as RadDocumentProcessing,telerikdocument processing ,Itextsharp etc .
|
|
|
|
|
You already have the names of 3rd party libraries. If you go and study them you should be able to decide which one suits your needs.
|
|
|
|
|
yes ok but i need a piece of code to extract tables from pdf and show on datatable in c#.
|
|
|
|
|
Yes, but you need to write the code first.
|
|
|
|
|
checkout their documentation
=====================================================
The grass is always greener on the other side of the fence
|
|
|
|
|
Problem
What layers required for make asp.net core 2 project for prevent repeat data ?
I need to make new project with asp.net core 2.1 using Generics and i have more questions
How many layers used ?
which layer must have initialize of connections ?
|
|
|
|
|
|
Anything related to data and database connection should be placed inside your Data Access layer. Anything related to Business rules and validation should be placed inside your Business Layer or whatever you want to call it.
|
|
|
|
|
In most of our web services I use the repository pattern. Isolating data access from business rules from controller/services.
Here is a link to some docs on Microsoft. This isn't specific to Dotnet Core, but the same pattern can still be applied.
|
|
|
|
|
I want c# code for image compression. Which can compress image without quality loss. I want to implement it in asp.net. Can you give me the code for compression
|
|
|
|
|
Google will find you samples.
|
|
|
|
|
Hi,
I have the following Web Api methods, I want to call and test my methods from a mocking application, if possible any code, following are my Web api methods:
[Produces("application/json")]
[Route("api/Employee")]
public class EmployeeController : Controller
{
EmployeeDataAccessLayer objemployee = new EmployeeDataAccessLayer();
[HttpGet("[action]")]
public IEnumerable<TblEmployee> Index()
{
return objemployee.GetAllEmployees();
}
[HttpPost]
public int Create(TblEmployee employee)
{
return objemployee.AddEmployee(employee);
}
[HttpGet("{id}")]
public TblEmployee Details(int id)
{
return objemployee.GetEmployeeData(id);
}
[HttpPut("{id}")]
public int Edit(int id, TblEmployee employee)
{
return objemployee.UpdateEmployee(employee);
}
[HttpDelete("{id}")]
public int Delete(int id)
{
return objemployee.DeleteEmployee(id);
}
[HttpGet("[action]")]
public IEnumerable<TblCities> GetCityList()
{
return objemployee.GetCities();
}
}
|
|
|
|
|
Mocking in tests is to replace the access of external resources with other things like hard-coded values so that you can test the business logic in your app independent of other things. So the short answer is that you would probably mock the entire web EmployeeController so that any code that calls the webapi would call your mocked controller instead.
If it is the controller itself you want to test then you would mock out the data access, in this case your EmployeeDataAccessLayer, so you could call the methods on your controller from a unit test without needing database access. However your controller methods don't really do anything, there is no logic in them, they just act as an interface to calls on the data access layer. So long story short, there is nothing here worth testing.
|
|
|
|