Skip to content

ErcanOPAK.com

  • ASP.Net WebForms
  • ASP.Net MVC
  • C#
  • SQL
  • MySQL
  • PHP
  • Devexpress
  • Reportviewer
  • About

Tag: if

ASP.Net MVC

How to use if else block to decide style in Razor

- 20.06.23 - ErcanOPAK comment on How to use if else block to decide style in Razor

Declare a local variable at the beginning of the View: @{ var yourStyle = “”; if(Model.Condition) { yourStyle = “float:left;”; //specific conditions and logic } else { yourStyle = “float:right;”; //any other conditions and logic } } and then just use it in your div: <div style=”@yourStyle”>

Read More
C#

The Ternary Operator in C# (?:)

- 13.12.22 - ErcanOPAK comment on The Ternary Operator in C# (?:)

C# includes a decision-making operator ?: called the conditional operator or ternary operator. It is the short form of the if-else conditions. Syntax: condition ? statement 1 : statement 2 The ternary operator starts with a boolean condition. If this condition evaluates to true then it will execute the first statement after ?, otherwise the second statement after : will […]

Read More
ASP.Net MVC

How to use ? : if statements with Asp.Net Razor

- 30.10.21 - ErcanOPAK comment on How to use ? : if statements with Asp.Net Razor

<span class=”btn btn-@(item.Value == 1 ? “primary” : item.Value == 2 ? “warning” : “danger”)”>EVALUATE</span> Briefly, we can say that @(condition ? “the value, if the condition is true” : “the value, if the condition is false” )

Read More
Reportviewer

How to use Switch in Reportviewer

- 06.10.21 | 06.10.21 - ErcanOPAK comment on How to use Switch in Reportviewer

= Switch(Fields!YourField.Value = “Value1”, “The result of the first condition”, Fields!YourField.Value = “Value2”, “The result of the second condition”, Fields!YourField.Value = “Value3”, “The result of the third condition”, 1 = 1 , “That is for the default value” ) 1=1 refers to default in switch case.   IF you want to use IIF then You […]

Read More
C#

How to Validate a DateTime in C#?

- 03.01.21 - ErcanOPAK comment on How to Validate a DateTime in C#?

DateTime myDate; if(DateTime.TryParse(txtBirthDate.Text, out myDate)) { //Valid Date } else { //Invalid Date }

Read More
C#

Determine If string contains more than 1 value in C#

- 16.03.20 | 29.03.20 - ErcanOPAK comment on Determine If string contains more than 1 value in C#

Let’s say you have a condition like that: if ((myString.Contains(“Value1”) && (myString.Contains(“Value2”)) && (myString.Contains(“Value3”))) { … } Basically, you want to check if all of your values are contained in the string . Fortunately (with the help of LINQ), this can by translated almost literally into C#: var values = new String[] {“Value1”, “Value2”, “Value3”}; if […]

Read More
C#

How to run code if not in Debug Mode in C#

- 11.03.20 - ErcanOPAK comment on How to run code if not in Debug Mode in C#

Sometimes you want to run your code only when it is not in debug mode. You can use #IF DEBUG code block for this purpose #if DEBUG LogMail(“It is in debug mode, only add a log record.”) #else SendMail(“It is not in debug mode, so you can send e-mail.”) #endif

Read More
November 2023
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
27282930  
« Oct    

Most Viewed Posts

  • Get the First and Last Word from a String or Sentence in SQL (694)
  • Get the User Name and Domain Name from an Email Address in SQL (691)
  • How to select distinct rows in a datatable in C# (550)
  • Add Constraint to SQL Table to ensure email contains @ (446)
  • Average of all values in a column that are not zero in SQL (366)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (336)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (333)
  • Find numbers with more than two decimal places in SQL (320)
  • Confirm before process with ASPxButton in Devexpress (313)
  • ASPxGridView – Disable CheckBox based on condition in GridViewCommandColumn (289)

Recent Posts

  • How to convert JPG or PNG to WebP in batch or single mode
  • How to get the first and the last day of previous month in SQL Server
  • Not Null check on LEFT function with T-SQL
  • NICE 100 YILLARA TÜRKİYEM
  • How to delete all commit history in github
  • How to display HTML components on the same line in CSS
  • How to insert results of a stored procedure into a temporary table
  • How to remove all non alphanumeric characters from a string in C#
  • How to get the Xth Day of the Week of the Year in C#
  • How to get formatted JSON in C#

Most Viewed Posts

  • Get the First and Last Word from a String or Sentence in SQL (694)
  • Get the User Name and Domain Name from an Email Address in SQL (691)
  • How to select distinct rows in a datatable in C# (550)
  • Add Constraint to SQL Table to ensure email contains @ (446)
  • Average of all values in a column that are not zero in SQL (366)

Recent Posts

  • How to convert JPG or PNG to WebP in batch or single mode
  • How to get the first and the last day of previous month in SQL Server
  • Not Null check on LEFT function with T-SQL
  • NICE 100 YILLARA TÜRKİYEM
  • How to delete all commit history in github

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter

© 2023 ErcanOPAK.com

Proudly powered by WordPress | Theme: Xblog Plus by wpthemespace.com