Saturday, December 18, 2021
To deploy a webapp on IIS server with visual studio
>Run visual Studio as administrator
>Click on "Build" and than click on "Publish"(screenshot below)
reference:- https://www.c-sharpcorner.com/UploadFile/b07128/deploy-Asp-Net-website-on-iis-in-our-local-machine/
How to register DLL file in Wondows?
>Run command(REGSVR32) in command prompt
> REGSVR32 (location of dll file)
How to change the .net version in Visual Studio?
>Click on Solution Explorer.
>Right click on Project.
>Click on "Property pages"(Screenshot below)
>Than click on BuildMultiple dataadapters in asp.net C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
String conStr = ConfigurationManager.ConnectionStrings["connectionStringCSD"].ConnectionString;
using (SqlConnection con = new SqlConnection(conStr))
{
using (SqlCommand cmd = new SqlCommand("Select Count(*) from db_accessadmin.SURVEY_MASTER_DATA_FILE_CORE", con))
{
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
con.Open();
int count = Convert.ToInt32(cmd.ExecuteScalar());
GridView1.VirtualItemCount = count;
con.Close();
}
using (SqlDataAdapter da1 = new SqlDataAdapter("Select top 10 A_Q102_STATE, A_Q103_DISTRICT, A_Q104_SUB_DISTRICT from db_accessadmin.SURVEY_MASTER_DATA_FILE_CORE", con))
{
DataTable dt = new DataTable();
da1.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
using (SqlDataAdapter da2 = new SqlDataAdapter("SELECT DISTINCT A_Q102_STATE FROM db_accessadmin.SURVEY_MASTER_DATA_FILE_CORE", con))
{
DataTable dt = new DataTable();
da2.Fill(dt);
ddlState.DataSource = dt;
ddlState.DataBind();
ddlState.Items.Insert(0, new ListItem("--Select State--", "0"));
}
}
}
}
}
Read text file in asp.net C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using RDotNet;
using RDotNet.NativeLibrary;
using RDotNet.Internals;
using RDotNetInstanceHelper;
public partial class Grid : Page
{
protected void Page_Load(object sender, EventArgs e)
{
int length = ReadFile(@"F:\\connection string for ODK.txt");
Response.Write(length);
}
static int ReadFile(string file)
{
int length = 0;
using (StreamReader reader = new StreamReader(file))
{
// Reads all characters from the current position to the end of the stream asynchronously
// and returns them as one string.
string s = reader.ReadToEnd();
length = s.Length;
}
return length;
}
}
https://www.c-sharpcorner.com/UploadFile/mahesh/how-to-read-a-text-file-in-C-Sharp/
await and async in asp.net C# (read txt file in asp.net) and get stored procedure
Asynchronous programming is very popular
When we are dealing with UI, and on button click, we use a long-running method like reading a large file or something else which will take a long time, in that case, the entire application must wait to complete the whole task. In other words, if any process is blocked in a synchronous application, the whole application gets blocked, and our application stops responding until the whole task completes.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using RDotNet;
using RDotNet.NativeLibrary;
using RDotNet.Internals;
using RDotNetInstanceHelper;
public partial class Grid : Page
{
protected async void Page_Load(object sender, EventArgs e)
{
//Task task = new Task(CallMethod);
Task<int> task = ReadFile(@"F:\\connection string for ODK.txt");
int length = await task;
Response.Write(length);
}
static async Task<int> ReadFile(string file)
{
int length = 0;
Console.WriteLine(" File reading is stating");
using (StreamReader reader = new StreamReader(file))
{
// Reads all characters from the current position to the end of the stream asynchronously
// and returns them as one string.
string s = await reader.ReadToEndAsync();
length = s.Length;
}
return length;
}
}
and
get stored procedure
reference:- https://www.webtrainingroom.com/aspnetmvc/async-task
reference:- https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/async
https://www.c-sharpcorner.com/article/async-and-await-in-c-sharp/
Tuesday, December 14, 2021
To get the machine name, username, domain name in C# ASP.NET
Response.Write(Environment.MachineName);
Response.Write(Environment.UserDomainName);
Response.Write(Environment.OSVersion);
To install packages in R Studio
>Download the package from https://cran.r-project.org/
>Click on packages
>Click on install
>Click on install from (package archive file .zip)
>Click on browse
>Select package and install(screenshot below)
ENUM in C# ASP.NET
namespace RDotNet.Graphics
{
public enum LineEnd
{
Round = 1,
Butt = 2,
Square = 3,
}
public enum LineJoin
{
Round = 1,
Miter = 2,
Beveled = 3,
}
Monday, December 13, 2021
R Programming examples
# import shiny package
library(shiny)
# define fluid page layout
ui <- fluidPage(
textInput(inputId = "num", label = "Choose a number",
value = "", width = 100, placeholder = NULL),
plotOutput("hist"),
verbatimTextOutput("stats")
)
server <- function(input, output)
{
# use reactive to create
# a reactive expression
data <- reactive({rnorm(input$num)})
output$hist <- renderPlot({hist(data())})
output$stats <- renderPrint({summary(data())})
}
# create shiny app object
# using shinyApp
shinyApp(ui = ui, server = server)
----------------------------****************-----------------------------
x <- seq(-pi, pi, 0.1)
plot(x, cos(x))
--------------------**************-------------------------------
v <- LETTERS[1:4]
for ( i in v) {
print(i)
}
Website with R Programming
For creating website, we have to use shiney package of R Programming
https://www.geeksforgeeks.org/shiny-package-in-r-programming/?ref=lbp
The output will be (screenshot below)
Bar chart in R language
# defining vector
x <- c(7, 15, 23, 12, 44, 56, 32)
# output to be present as PNG file
png(file = "barplot.png")
# plotting vector
barplot(x, xlab = "GeeksforGeeks Audience",
ylab = "Count", col = "white",
col.axis = "darkgreen",
col.lab = "darkgreen")
# saving the file
dev.off()
references:-https://www.geeksforgeeks.org/r-charts-and-graphs/
Pie Chart demo in R language
# Creating data for the graph.
x <- c(20, 65, 15, 50)
labels <- c("India", "America", "Shri Lanka", "Nepal")
# Giving the chart file a name.
png(file = "Country.jpg")
# Plotting the chart.
pie(x,labels)
# Saving the file.
dev.off()
reference :- https://www.javatpoint.com/r-pie-charts
Thursday, December 9, 2021
Installation on web site environment in Rstudio
>Click on tutorials
>Click on learnR package (screenshot below)
>Now you can able to create website
>Click on File>New and create new application(screenshot below)
Sequence function in c#
var seq = Enumerable.Range(0, 10);
refernce :-https://stackoverflow.com/questions/4588787/how-to-create-a-sequence-of-integers-in-c
R programming language RStudio How to change the background color of window
>First open RStudio
>Goto tools>options
>Goto appearance and Select the editor theme.(screenshot below)
To run R programming language GUI
To run R programming language GUI
Goto
C:\Program Files\R\R-4.1.2\bin\i386\Rgui.exe
For installation of R programming language
>First download the below link
https://cran.r-project.org/bin/windows/base/
>Second download R studio
https://www.rstudio.com/products/rstudio/download/
reference:- https://www.javatpoint.com/r-installation
Wednesday, December 8, 2021
Calling a web service from Jquery
Also uncomment the following code to run the code without error
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
https://www.c-sharpcorner.com/blogs/how-to-call-asp-net-web-service-using-jquery-ajax
Asp.Net AccessDataSource control in asp.net
<asp:AccessDataSource runat="server" ID="access" DataSourceMode="DataSet"
DataFile="~/Database4.mdb" SelectCommand="SELECT * FROM [Employee]"></asp:AccessDataSource>
if you want to connect microsoft access to .net, in gridview. Use asp:AccessDataSource(below is the screenshot of MS access table)
reference:- https://www.c-sharpcorner.com/uploadfile/raj1979/accessdatasource-control-in-Asp-Net-3-5/
https://www.msdotnet.co.in/2016/10/how-to-access-microsoft-access-database.html#.YbBX6dBBzIU
Page events in visual studio
>Open solution explorer in Visual Studio
>Right click on aspx page
>Click on "view component Designer"
>Than go to events and create the events (preinit, page load etc.){screenshot below}
ValidationGroup property in textbox, requiredfieldvalidator asp.net c#
https://www.c-sharpcorner.com/blogs/use-of-validation-group-in-asp-net1
SQLDatasource in Dropdown list in asp.net C#
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:test %>"
SelectCommand="SELECT [ID], [Name] FROM [Customer]"></asp:SqlDataSource>
<asp:DropDownList runat="server" ID="ddlState"
AppendDataBoundItems="True" DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="ID">
<asp:ListItem Text="yash" Value="0" ></asp:ListItem>
<asp:ListItem Text="naveen" Value="1"></asp:ListItem>
<asp:ListItem Text="demo" Value="2"></asp:ListItem>
</asp:DropDownList>
Tuesday, December 7, 2021
Autopostback in dropdown list in asp.net C#
Autopost back is used to post the request to server when we change the selected value in drop down list.
if we set autopostbak property to false than while changing the selected value, page will not refresh.
ASP.Net all the properties of textbox
https://www.educba.com/asp-dot-net-textbox/
placeholder property is used to give the blank text of textbox.
Textbox column property in asp.net C#
Textbox column property is used to increase or decrease the width of textbox.
Difference between ONclientClick and onClick event in Asp.net button
onClientClick works on client side and onclick works on server side.
<asp:Button Text="Get TextBox Details" runat="server" OnClientClick="return GetTextBoxDetails()" />
reference:- https://www.c-sharpcorner.com/blogs/difference-between-onclick-and-onclientclick1
AutoPostback in textbox asp.net C#
In asp.net if we make the autopostback property to true, than we have to use textcahnge event.
And we can use it on enter key.
reference:- https://asp-net-example.blogspot.com/2009/03/how-to-use-autopostback-feature-in_27.html
PostBackUrl property in asp.net button
It works as response.redirect function
<asp:Button runat="server" ID="btnMoveToNextPage" Text="Move to Page" PostBackUrl="~/RDLC.aspx" />
ISPostback in asp.net in page_load event C#
When clicking on button, that goes to ispostback condition and when redirecting from one page to another that goes to (!ispostback) condition
protected void Page_Load(object sender, EventArgs e)
{
if(IsPostBack)
{
btnClickMe.Enabled = false;
}
else
{
btnClickMe.Enabled = true;
}
}
EnableViewState in Textbox ASP.net
By default in ASP.net enableviewstate is true. If you make it false, when you click on button, it will change the color of textbox after clicking the button.
https://www.c-sharpcorner.com/UploadFile/ee01e6/viewstate-for-textbox-in-Asp-Net/
Monday, December 6, 2021
DIV onscroll function in javascript
<div onscroll="myfunction()">
</div>
function myfunction()
{
}
d3.select("#divColumnRight")
.on("scroll", function(){
//statements
});
SVG text inside x and y axis
svg.append("text")
.style("fill", "black")
.attr("x", 200)
.attr("y", 100)
.text("Hello World");
refereces:- d3nood.org/2014/02/d3js-elements.html
leanpub.com/d3-t-and-t-v4/read
SVG path in D3JS
svg.append("path")
.style("stroke", "black")
.style("fill","none")
.attr("d", "M 100, 50, L 200, 150, L 300, 50 Z");
//output will be Upside down triangle
To get the parent node in d3js
d3.select("grid"). nodes()[0].
parentNode.setAttribute("transform", "translate('1px, 3px'));
To set the property in d3js (background color)
d3.select("divID").
node().style
.setProperty("background", "black");
or
setProperty("transform", "translate("0px, 50px")");
Filter of array that starts with in Javascript
UniqueTrainIDArr.filter(a=>a.startsWith("2"))
UniqueTrainIDArr.filter(a=>a==d.key)
Difference between polyline and Line Chart in d3js
Polyline is more fast than Line chart in D3JS.
So we can use polyline chart.
Javascript filter By ID
uiniqueTrainID.filter(a=>a==d.key).length>0;
uniqueTrainIDArr.filter(a=>a==d.key)==d.key;
Map function in D3JS, Select one value from TSV file
d3.tsv("abc.tsv", function(data){
var val = d3.set(data.map(function(d){
return d.trainID})).values());
Filtering (startwith) of array in Javascript
const countries = ["Norway", "sweden", "Denmark", "New Zealand"];
const startsWithN = countries.filter((country)=>country.startsWith("N"));
console.log(startsWithN)
//Output
["Norwing", "NewZealand"]
How to Enable Dark Mode in Windows 10 and
https://www.hellotech.com/
Also in this we can change accent color(Check the automatically pick an accent color from my background)
ENUM in javascript
enum Direction{up =1, down, left, right}
enum Response{No = 0, Yes = 1}
enum color {Red, Green}
To make dotted lines or dashed lines on yaxis
svg.selectAll(".grid")
.data(uniqueDistanceArr)
.enter.append("g")
.attr("class", "grid")
.attr("transform", "translate(194, '+10+')")
.style("stroke-dasharray", function(d){
return(5+","+yscalestatiocode(d)+");})
.call(make_x_gridlines()
.tickSize(-height)
.tickFormat("")
.ticks(d3.timeMinute.every(2))
)
or
svg.selectAll('.grid')
.data(d3.timeMinute.range(data[0].arrivalTime, data[data.length-1].departuretime, 2))
.enter().append("g")
.attr("class", "grid")
.attr("transform", translate(50, "+10+")"))
.style("stroke-dasharray", function(d){
return(1+","+xscale(d)+"");
})
.call(make_y_gridlines()
.ticksize(-width)
.tickFormat(""))
To print div in javascript
var divContents = document.getElementById("divColumnsRight").innerHTML;
var a = window.open("", "", 'height = 500, width = 500");
a.document.write("<html>");
a..document.write("<body><h1> div content <br>");
a..document.write(divContents);
a..document.write("</body></html>");
a.document.close();
a.print();
To remove elements by class name
d3.select("path.line").remove();
d3.selectAll("path.line").remove();
function in Javascript
function myFunction(p1, p2) {
return p1 * p2; // The function returns the product of p1 and p2}
To create dropdown list or select option in d3js (at runtime) programatically
d3.select(#divColumnLeft)
.append("select")
.attr("name", "stationcode")
.attr("id", "selectstationcode")
.selectAll("myoptions")
.data(data).enter()
.append("option")
.text(function(d){return d;})
.attr('value', function(d){return d;});
d3.select("#selectStationCode")
.on("change", function(d){
var selectedOption = d3.select(this).property("value");
});
To create SVG in DIV in d3js
var svg = d3.select("#divColumnRight");
d3.select("body")
.append("svg")
.attr("width", 500)
.attr("height", 600)
.append("g")
.attr("transform", "translate(50, 0)");
//(translate(y axis left margin, x axis top margin))
To create anchor tag in HTML or create at run time
<a id="download" href="/a.png"> download </a>
or to create anchor tag on runtime
var a = document.createElement("a");
a.download = "a.png";
a.href = "google.com/a.png";
a.click();
To enable or disable network connection(wifi connection)
ncpa.cpl
or goto Control panel
>Network and sharing centre
>Click on change adapter settings
To create label in D3js
d3.select("divColumnLeft").
append("label").attr("for", "stationCode")
.text("Station Code");
Saturday, December 4, 2021
Garbage Collector in c# asp.net
garbage collector in c# is a technique to free up the unused space in the memory.
reference:- https://www.c-sharpcorner.com/UploadFile/skumaar_mca/garbage-collection-in-net-framework/
Difference between dataset and datatable
Datatable holds single table
Dataset holds multiple table.
references:- https://www.webcodeexpert.com/2013/03/difference-between-dataset-and.html
Friday, December 3, 2021
How to upload file in asp.net(File upload control) - Custom validator - Server side validation ASP.NET c#
https://www.c-sharpcorner.com/article/Asp-Net-2-0-fileupload-control/
or advance functioning
HTML code(aspx)
<div id="Div_Invoice_CF" runat="server" visible="false">
<asp:FileUpload ID="fld_Invoice_CF" CssClass="form-control" runat="server" />
<asp:CustomValidator ID="CustomValidator1" runat="server" Display="Dynamic" ForeColor="Red"
ErrorMessage="" ValidationGroup="a" SetFocusOnError="true" ControlToValidate="fld_Invoice_CF"
OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Display="None"
ErrorMessage="Please Upload Invoice Copy" ControlToValidate="fld_Invoice_CF"
ValidationGroup="a" CssClass="ValidatorCallout" SetFocusOnError="True"></asp:RequiredFieldValidator>
<cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" TargetControlID="RequiredFieldValidator24">
</cc1:ValidatorCalloutExtender>
<span style="padding:15px">
How to show XML file in GRid and XML control in asp.net
https://www.c-sharpcorner.com/UploadFile/18fc30/displaying-xml-data-in-Asp-Net-gridview/
------------------------*******************------------------------------
<asp:Xml runat="server" DocumentSource="~/Brother name.xml" />
Dark theme or mode in windows
>Click on Start
>Type settings
>Click on colors
>Click on choose your color.
reference:- https://support.microsoft.com/en-us/windows/change-colors-in-windows-d26ef4d6-819a-581c-1581-493cfcc005fe
Dark theme or mode in visual studio and SQL server
>In visual studio, click on tools
>Click on options
>Click on general under environment
>Select color theme "Dark"(screenshot below)
--------------------------------**************-------------------
In SQL server, GO to file (C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE)
and open the file ssms.pkgundef in visual studio
Comment the line remove dark theme
reference:-(https://sqlskull.com/2020/06/01/enable-dark-theme-in-sql-server-management-studio/)
__________________________******************___________________________
or you can see the below link
How to install RDLC in Visual Studio
> Click on Tools>Nuget Package manager
> In Nuget package manager Type (Install-Package Microsoft.ReportingServices.ReportViewerControl.WebForms -Version 150.1484.0)
Reference (https://www.nuget.org/packages/Microsoft.ReportingServices.ReportViewerControl.WebForms/)
>Now click on 'Toolbox'.
>Right Click on it.
>Click on Add tab
>Right click and click on choose items.
>Click on browse and select "Microsoft.ReportViewer.WebDesign.dll"
>Click on OK
Reference(https://www.c-sharpcorner.com/article/install-rdlc-extensions-in-visual-studio-2017/)
>Click on Tools
>Click on "Nuget Package manager"
>Click on "Manage Nuget packages for solution"
>Type "Microsoft.ReportViewer.webforms" or "Microsoft.ReportViewer.webforms.2010" and install it.
>At last relaunch visual studio.
>Write the below code
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server"></rsweb:ReportViewer>
</div>
> use the below reference for full code.
or
>Open visual studio
> Go to 'Extensions'
> In search box type 'report viewer'
>Click on 'Microsoft RDLC Report Designer' and click on download
(Now Report and report wizard will display)
or
Go to tools >Click on 'Get tools and features'
> Do the below steps
https://stackoverflow.com/questions/42084161/how-to-open-an-rdl-file-in-visual-studio
https://learn.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt?view=sql-server-ver16
Thursday, December 2, 2021
python request example
import requests
x = requests.get('https://w3schools.com/python/demopage.htm')
print(x.text)
How to add reference in visual studio python project
Right click on add reference and click on manage and type (for example:- requests).
web.config file directory enable to true(IIS server directory enable to true)
<configuration>
<system.webServer> <directoryBrowse enabled="true" showFlags="Date,Time,Extension,Size" /> </system.webServer> </configuration>Wednesday, December 1, 2021
See tables in views SQL server
> In sql server we can see, all the tables in views(expand the database)
> In views sys.tables, you can see the tables.And there are many views.
Group By with having clause
SELECT COUNT(ID) FROM EMPLOYEE GROUP BY NAME HAVING COUNT(ID)>1
having is used with group by and count.