반응형

C#/ASP.net 15

ASP.net asp:Button컨트롤러 버튼에 Bootstrap의 CSS class 입히기

ASP.net의 Master페이지가 있는 WebForm에서, Button컨트롤러에 CSS Class을 입히는 간단한 방법을 소개합니다. 일반적인 웹 폼에서 Button컨트로러에는 CSS가 전혀 입히지 않는 기본 버튼 모양인데요. 마스터 페이지에 있는 Bootstrap를 이용해서, 이미 제작된 CSS Class에 값을 줘서 디자인을 적용해 보는 예제입니다. 코드에서 직접 입력해도 되고요. 속성의 CssClass값에 입력해도 적용이 됩니다. [ asp:Button 객체에 class입히기 ] CssClass="btn btn-primary" 기본 예제 예제 > You have to use asp:LinkButton instead of a asp:Button, here is how it works for me u..

C#/ASP.net 2021.01.29

ASP.net DropDownList 값 선택하기, Select 선택값 변경시 함수 처리하기

웹에서 사용되는 요소의 기능들을 ASP.NET에서는 DropDownList 객체로 쉽게 처리할 수 있게 되어 있습니다. 쉽게 생각해서, C#에 요소의 표준 객체가 DropDownList로 보면 됩니다. 여기서, 우리는 2가지를 이야기하려고 합니다. (1) DropDownList 컨트롤러의 값 선택하기 (2) DropDownList 컨트롤러의 선택이 변경될 때 처리하기 기본적으로 웹에서는 이런 기능들을 html이벤트와 Javascript를 통해서 처리하지만, ASP.NET 에서는 이벤트와 CodeBehind 소스를 통해서 처리합니다. (1) DropDownList 컨트롤러에 값 선택하기 DropDownList 컨트롤에서 특정 값의 Item을 선택하게 하려면, 객체를 Item를 찾아서 value부분에 값을 ..

C#/ASP.net 2021.01.28

ASP.net 유효성 검사 CompareValidator / CauseValidation

웹 프로그램을 하다보면, 유효성 검사가 필요합니다. ASP.net의 경유 "유효성 검사" 도구들을 이용해서, 조금더 쉽게 유효성 검사 프로그램을 만들 수 있습니다. 유효성 검사란? 사용자가 입력하는 값에서 사용자의 실수를 막고, 잘못된 입력된 값을 차단함으로써, 사용자의 실수와 프로그램의 오류를 사전에 방지할 수 있는 역할을 할 수 있습니다. 유효성 검사 - CompareValidator "기본이 되는 값"과 "대상이 되는 값"을 비교해서 일치하지 않으면 실패 처리 - 비교 대상이 없으면, 검사 성공으로 처리됨 - 기본적으로 RequiredFieldValidator를 제외한 모든 Validator은 null을 허용 - 비교: 같다, 같지 않다, 크다, 작다, 크거나 같다, 작거나같다, 자료형이 같다. 속..

C#/ASP.net 2021.01.28

Mail 발송하기 예제 (System.Net.Mail)

ASP.net에서 System.Web.Mail을 이용해서, 메일을 보내는 소스예제 참고: 보통 이메일을 전송하는 SMTP 방식에는 인증과 비인증 방식있다. SMTP서버가 인증 방식을 필요로 하는 경우, 반드시 SMTP Account를 통한 인증을 가져 가야 합니다. Gmail의 SMTP서버를 이용한 예제 using System.Net.Mail void example() { MailMessage message = new MailMessage(); message.From = new MailAddress("계정명@gmail.com"); message.To.Add(new MailAddress(test@localhost.com)); message.IsBodyHtml = true; message.Subject = ..

C#/ASP.net 2018.10.25

Visual Studio를 이용한 ASP.net 웹 배포:테스트 환경에 배포

https://docs.microsoft.com/ko-kr/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/deploying-to-iis Visual Studio를 사용 하 여 ASP.NET 웹 배포: 테스트 환경에 배포 개요 이 자습서에서는 로컬 컴퓨터의 IIS에 ASP.NET 웹 응용 프로그램을 배포 하는 방법을 보여 줍니다. 응용 프로그램을 개발할 때 일반적으로 Visual Studio에서 실행 하 여 테스트 합니다. Visual Studio 2012에서 웹 응용 프로그램 프로젝트 기본적으로 개발 웹 서버로 IIS Express를 사용 합니다. IIS Express는 기본적으로 Visual Studio 2010에는 Visual S..

C#/ASP.net 2018.09.26

asp:textbox에 placeholder 입력값 예제 만들기

asp 페이지의 asp:textbox 에 힌트로 보여질 html5에서 사용되는 placeholder 에 해당하는 문자 나오게 하기.컨트롤러에 placeholder 애튜리뷰트를 추가하기. (아래의 방법이 가장 간단한 방법) 그외의 방법들도 소개합니다. The placeholder attributeYou're looking for the placeholder attribute. Use it like any other attribute inside your ASP.net control:Don't bother about your IDE (i.e. Visual Studio) maybe not knowing the attribute. Attributes which are not registered with ASP...

C#/ASP.net 2018.05.08

URL중에 http://도메인:PORT 구하기

ASP.net에서 *.aspx.cs에서 Domain:Port부분을 뽑아서 사용이 필요할때가 있습니다. 예를 들어서, http://test.net:8080과 같이 나올때, 도메인을 쉽게 뽑아내는 ASP.net 소스 // Domain Uri uri = Context.Request.Url; ViewState["Domain"] = HttpContext.Current.Request.Url.Host; //포트가 80이 아니면, 특정 Port 붙여주기. if (uri.Port != 80) ViewState["Domain"] = ViewState["Domain"] + ":" + uri.Port; // 활용 _body = _body.Replace("###HOME_URL###", "http://" + ViewState["..

C#/ASP.net 2018.04.27

WCF Web HTTP Service Help Page만들기 (URI, Method-GET/POST등)

.net Framework 4.6.1에서 WCF WEB HTTP를 위한 Help page를 자동으로 생성됩니다. 예를 들어 다음과 같이 "/help"을 붙이면 다음과 같이 나타납니다. (예: http://localhost:8000/Customers/Help ) Using the WCF Web HTTP Help Page The WCF WEB HTTP Help page displays a short description for each operation provided that you specify one using the DescriptionAttribute. This attribute takes a string that contains a short description of the operation i..

C#/ASP.net 2017.10.06

DB Connection 실패시 나오는 에러 (방화벽이 차단했을경우등) SqlException (0x80131904)

방화벽이 차단했을 경우의 에러 메시지입니다.결론, DB network접속이 실패 하는 경우입니다.[Win32Exception (0x80004005): The network path was not found][SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (p..

C#/ASP.net 2017.09.28

에러: Object cannot be cast form DBNull to other types.

형변환에서 오류가 발생하는 것들이 생길수 있습니다.decimal _tip_total = 0;_tip_total += Convert.ToDecimal(row["TIP_ADJUST"]); 해당 값이 Null값일때, 다음과 같은 오류가 발생합니다. (해결법)string.IsNullEmpty()를 이용해서 체크를 하던지.해당 부분의 쿼리부분에서 isnull(TIP_ADJUST,0) 처럼 널처리를 하던지. 둘중에 하나를 사용하면 됩니다.

C#/ASP.net 2017.08.30

c# fileupload exists (파일 존재 여부 체크) Image 파일만 체크

ASP.net c#에서 파일 업로드시 파일 이름이 존재한다면, 해당 파일 이름이 아닌 다른 이름으로 입력하게 하는 로직입니다. 먼저, 파일 존재 여부 체크bool System.IO.File.Exists(string path) [파일 이름이 중복시 램덤으로 만들기] // Video fileif (FileUpload2.HasFile){ var extention = System.IO.Path.GetExtension(FileUpload2.FileName);strOtherFileName = Path.GetFileName(FileUpload2.FileName);// Gets only file name.int intOtherFileSize = FileUpload2.FileBytes.Length; strOtherFil..

C#/ASP.net 2017.06.10

[.net MVC Core] .Net Core 플랫폼 받기

개발툴 받은후, .Net Core 을 받아야 합니다. https://www.microsoft.com/net Download > .Net Core 선택 > SDK를 다운로드 받으시면 됩니다.(해당 프로그램은 컨맨트 컨설을 실행 할수 있게 합니다.) VS 2015 Windows PowerShell에서>cd desktop>mkdir aspnetcore>cd aspnetcore>dotnet new VS 2017 설치되었다면 (https://www.microsoft.com/net/core#windowscmd ) Windows PowerShell에서> dotnet new console -o hwapp> cd hwapp> dotnet restore> dotnet run c# 프로젝트가 생성됩니다.

C#/ASP.net 2017.04.28

[.net MVC Core] Model의 Data의 DisplayFormat 바꾸기 (날짜, 통화)

MVC에 Model에서 데이터어노테이션을 통해서, 모델의 표시를 바꿔보도록 합니다. public class CostChart { public string itemType { get; set; } [DataType(DataType.Currency)] public float? Cost{ get; set; } } Alternatively, you could use?DataFormatString?like this: [DisplayFormat(DataFormatString = "{0:C0}")]` public float? Cost{ get; set; } But I prefer to set the display format with?EditorFor. Here's a great tutorial on Extendin..

C#/ASP.net 2017.04.26
1
반응형