Skip to content

ErcanOPAK.com

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

Category: ASP.Net MVC

ASP.Net MVC / Razor

How to put text inside MVC Razor code block

- 20.05.22 - ErcanOPAK comment on How to put text inside MVC Razor code block

The contents of a code block ({ … }) are expected to be code or markup (tags), not plain text. If you want to put text directly in a code block, you have three choices: Wrap it in any HTML tag Wrap it in the special Razor <text> tag, which will just render the text without the […]

Continue Reading ..
ASP.Net MVC / ASP.Net WebForms / HTML

How to get the integrity value for a jquery version of script reference in a web page

- 26.04.22 - ErcanOPAK comment on How to get the integrity value for a jquery version of script reference in a web page

You can use https://www.srihash.org/ to generate links. https://code.jquery.com/jquery-3.6.0.min.js will be generated as <script src=”https://code.jquery.com/jquery-3.6.0.min.js” integrity=”sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==” crossorigin=”anonymous”></script> You can get all the versions of jquery from here: https://releases.jquery.com/jquery/ Thanks to mscdeveloper for such great post.

Continue Reading ..
ASP.Net MVC / ASP.Net WebForms / JavaScript

How to get session value in Javascript

- 16.04.22 - ErcanOPAK comment on How to get session value in Javascript

<script> let mySession = ‘<%= Session[“SessionName”].ToString() %>’; //use your session … console.log(mySession); alert(mySession); </script>  

Continue Reading ..
ASP.Net MVC / ASP.Net WebForms / C#

How to get value from resx file in C#

- 26.03.22 - ErcanOPAK comment on How to get value from resx file in C#

// Gets the value of associated with key “MyKey” from the local resource file (“~/MyPage.aspx.en.resx”) or from the default one (“~/MyPage.aspx.resx”) //The default location for resx files is App_LocalResources object keyValue = HttpContext.GetLocalResourceObject(“~/MyPage.aspx”, “MyKey”);

Continue Reading ..
ASP.Net MVC / ASP.Net WebForms / Razor

How to insert space in Razor Asp.Net

- 09.01.22 - ErcanOPAK comment on How to insert space in Razor Asp.Net

@if (condition) { <text>&nbsp;</text> @:&nbsp; }  

Continue Reading ..
ASP.Net MVC / ASP.Net WebForms / HTML / JavaScript

Search text through Divs in Javascript

- 29.12.21 - ErcanOPAK comment on Search text through Divs in Javascript

<table align=”center” width=”20%”> <tr> <td style=”padding-right: 10px”> <input type=”text” id=”Search” onkeyup=”myFunction()” placeholder=”Please enter a search term..” title=”Type in a name”> </td> </tr> </table> <br> <div class=”target”> This is my DIV element. </div> <div class=”target”> This is another Div element. </div> <div class=”target”> Can you find me? </div> <script> function myFunction() { var input = document.getElementById(“Search”); […]

Continue Reading ..
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” )

Continue Reading ..
ASP.Net MVC / ASP.Net WebForms

How to wrap very long text in Asp.Net Razor

- 27.10.21 - ErcanOPAK comment on How to wrap very long text in Asp.Net Razor

That will save you: <div style=”word-break: break-all;”> THEVERYVERYLOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONGTEXT </div>  

Continue Reading ..
ASP.Net MVC

Getting index value in Razor ForEach

- 24.10.21 - ErcanOPAK comment on Getting index value in Razor ForEach

@{int i = 0;} @foreach(var myItem in Model.Members) { <span>@i</span> @{i++;} }  

Continue Reading ..
ASP.Net MVC / JavaScript

Populating Javascript array with Model in ASP.Net MVC Razor

- 23.10.21 - ErcanOPAK comment on Populating Javascript array with Model in ASP.Net MVC Razor

We just need to loop through the razor collection to populate the Javascript array as below: @foreach (var item in Model) { @:$(function () { @:$(“#map”).googleMap(); @:$(“#map”).addMarker({ @:coords:[@item.Latitude], @:title: `@item.City, @item.District`, @:text: `@item.Address` @:}); @:}); }  

Continue Reading ..
ASP.Net MVC / C# / JavaScript

Pass model from Razor view to JavaScript

- 23.10.21 - ErcanOPAK comment on Pass model from Razor view to JavaScript

Let’s say you send a model called “MyModel” from controller to view. In Controller: … var result = new MyModel() { Id = 1, Name = “Ercan”, FavoriteTeam = “Galatasaray”, FavoriteGame = “Half Life Series” } return View(result); … and now we will send this model which comes with result to Javascript via setName function: […]

Continue Reading ..
ASP.Net MVC / ASP.Net WebForms / JavaScript

Getting Session value in Javascript & Asp.Net

- 29.09.21 - ErcanOPAK comment on Getting Session value in Javascript & Asp.Net

<script> var mySessionValue = ‘<%= Session[“SessionName”].ToString() %>’; alert(mySessionValue); </script>  

Continue Reading ..
ASP.Net MVC / C#

How to add placeholder to Multiple Selection DropDownList in Asp.Net MVC

- 02.01.21 - ErcanOPAK comment on How to add placeholder to Multiple Selection DropDownList in Asp.Net MVC

@Html.ListBox( “Countries”, ViewBag.AllCountries as MultiSelectList, new { @class = “form-control”, data_placeholder = “Choose a Country…” } )

Continue Reading ..
ASP.Net MVC / C#

Convert List to List in one line in C#

- 08.10.20 - ErcanOPAK comment on Convert List to List in one line in C#

string sNumbers = “1,2,3,4,5”; var numbers = sNumbers.Split(‘,’).Select(Int32.Parse).ToList();

Continue Reading ..
ASP.Net MVC / ASP.Net WebForms / JavaScript

How to use column search in datatable when responsive is false

- 18.09.20 - ErcanOPAK comment on How to use column search in datatable when responsive is false

just add “$(“th”).show();” in the end of initComplete … , initComplete: function () { … $(“th”).show(); } , …  

Continue Reading ..
ASP.Net MVC / ASP.Net WebForms / C#

Checking multiple contains on one string

- 30.08.20 - ErcanOPAK comment on Checking multiple contains on one string

new[] {“,”, “/”}.Any(input.Contains) or you can use Regex Regex.IsMatch(input, @”[,/]”);

Continue Reading ..
ASP.Net MVC

How to render HTML tags Asp.Net MVC

- 25.08.20 - ErcanOPAK comment on How to render HTML tags Asp.Net MVC

string myValue = “<b>Hello</b>”; @Html.Raw(HttpUtility.HtmlDecode(myValue))

Continue Reading ..
ASP.Net MVC / ASP.Net WebForms / JavaScript

How to refresh a DIV content with Javascript

- 23.07.20 - ErcanOPAK comment on How to refresh a DIV content with Javascript

To reload a section of the page, you could use jquerys load with the current url and specify the fragment you need, which would be the same element that load is called on, in our below case #myDivId function updateDivContent() { $(“#myDivId”).load(window.location.href + ” #myDivId” ); }

Continue Reading ..
Page 1 of 2
1 2 Next »

Posts navigation

Older posts
May 2022
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
« Apr    

Most Viewed Posts

  • Get the First and Last Word from a String or Sentence in SQL (332)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (221)
  • Find numbers with more than two decimal places in SQL (191)
  • How to solve “Response.Redirect cannot be called in a Page callback” for DevExpress Components (190)
  • Confirm before process with ASPxButton in Devexpress (189)
  • ASPxGridView – Disable CheckBox based on condition in GridViewCommandColumn (189)
  • How to make some specific word(s) Bold or Underline in ReportViewer (189)
  • Devexpress ASPxGridview Column Grouping in Code (177)
  • Add Constraint to SQL Table to ensure email contains @ (174)
  • Tense Changes When Using Reported Speech (167)

Recent Posts

  • How to put text inside MVC Razor code block
  • How to solve 0xc0000135 application errors after Windows 11 Update
  • How to get the integrity value for a jquery version of script reference in a web page
  • How to get session value in Javascript
  • How to get value from resx file in C#
  • How to lock the ciritical code part in C#
  • How to make theater mode the default for Youtube
  • How to turn off YouTube annotations and cards
  • How to hide Youtube chat windows permanently
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server

Recent Posts

  • How to put text inside MVC Razor code block
  • How to solve 0xc0000135 application errors after Windows 11 Update
  • How to get the integrity value for a jquery version of script reference in a web page
  • How to get session value in Javascript
  • How to get value from resx file in C#

Most Viewed Posts

  • Get the First and Last Word from a String or Sentence in SQL (332)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (221)
  • Find numbers with more than two decimal places in SQL (191)
  • How to solve “Response.Redirect cannot be called in a Page callback” for DevExpress Components (190)
  • Confirm before process with ASPxButton in Devexpress (189)

Social

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

powered by XBlog Plus WordPress Theme