"Whatever happened, happened for the good; whatever is happening, is happening for the good; whatever will happen, will also happen for the good only. You need not have any regrets for the past. You need not worry for the future." - Bhagavad Gita
Tuesday, February 25, 2020
Monday, February 24, 2020
search text file using c# and display the line number and the complete line that contains the search keyword
Sample Input:
just a sample line
another sample line
first matching Order line
not a match
...here's a Order match
Order 123
foreach (var match in File.ReadLines(@"c:\LogFile.txt")
.Select((text, index) => new { text, lineNumber = index+ 1 })
.Where(x => x.text.Contains("Order ")))
{
Console.WriteLine("{0}: {1}", match.lineNumber, match.text);
}
Output:
3: first matching Order line
5: ...here's a Order match
6: Order 123
Sunday, February 23, 2020
How can i call a server side button click function from client side?
option is to simulate Click of a button using javascript.
<asp:Button ID="savebtn" runat="server" OnClick="savebtn_Click" style="display:none" />
HTML markup will look like this:
<button id="btnsave" onclick="fncsave()">Save</button>
now simulate a Click using JS
<script type="text/javascript">
function fncsave()
{
document.getElementById('<%= savebtn.ClientID %>').click();
}
</script>
<asp:Button ID="savebtn" runat="server" OnClick="savebtn_Click" style="display:none" />
HTML markup will look like this:
<button id="btnsave" onclick="fncsave()">Save</button>
now simulate a Click using JS
<script type="text/javascript">
function fncsave()
{
document.getElementById('<%= savebtn.ClientID %>').click();
}
</script>
Friday, February 21, 2020
How use hidden field value in updatepanel
Any asynchronous round trips to the server will cause only those controls within the UpdatePanelitself to update on the UI, so even though the code-behind runs and updates the hidden fields, on the front end they stay the same because they sit outside the panel.
Try moving the hidden fields within the <ContentTemplate> tag
Try moving the hidden fields within the <ContentTemplate> tag
<asp:UpdatePanel ID="upTripsGrid" runat="server" UpdateMode="Always"> <ContentTemplate> <input type="hidden" runat="server" id="hidCurrentDate" value="" /> <input type="hidden" runat="server" id="hidTripIds" value="" /> </ContentTemplate> </asp:UpdatePanel>
Wednesday, February 19, 2020
How do I copy to the clipboard in JavaScript?
html page:
<button onclick="copyToClipboard();return false">copy to the clipboard</button>
<asp:HiddenField runat="server" ID="hdnCopyContent" ClientIDMode="Static" value="clipboard in JavaScript" />
Javascript function
function copyToClipboard() {
var text = $("input[Id$='hdnCopyContent']").val();
if (text != undefined || text != null || text != "") {
alert(text);
}
if (window.clipboardData && window.clipboardData.setData) {
// IE specific code path to prevent textarea being shown while dialog is visible.
return clipboardData.setData("Text", text);
} else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
var textarea = document.createElement("textarea");
textarea.textContent = text;
textarea.style.position = "fixed"; // Prevent scrolling to bottom of page in MS Edge.
document.body.appendChild(textarea);
textarea.select();
try {
return document.execCommand("copy"); // Security exception may be thrown by some browsers.
} catch (ex) {
console.warn("Copy to clipboard failed.", ex);
return false;
} finally {
document.body.removeChild(textarea);
}
}
}
<button onclick="copyToClipboard();return false">copy to the clipboard</button>
<asp:HiddenField runat="server" ID="hdnCopyContent" ClientIDMode="Static" value="clipboard in JavaScript" />
Javascript function
function copyToClipboard() {
var text = $("input[Id$='hdnCopyContent']").val();
if (text != undefined || text != null || text != "") {
alert(text);
}
if (window.clipboardData && window.clipboardData.setData) {
// IE specific code path to prevent textarea being shown while dialog is visible.
return clipboardData.setData("Text", text);
} else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
var textarea = document.createElement("textarea");
textarea.textContent = text;
textarea.style.position = "fixed"; // Prevent scrolling to bottom of page in MS Edge.
document.body.appendChild(textarea);
textarea.select();
try {
return document.execCommand("copy"); // Security exception may be thrown by some browsers.
} catch (ex) {
console.warn("Copy to clipboard failed.", ex);
return false;
} finally {
document.body.removeChild(textarea);
}
}
}
Why does xcopy exit with code 9009 in Visual Studio post-build step?
xcopy "$(ProjectDir)config\Web.config.$(ConfigurationName)" "$(ProjectDir)Web.config" /Y/R
"'xcopy' is not recognized as an internal or external command."
I then changed my statement to:
C:\Windows\System32\xcopy "$(ProjectDir)config\Web.config.$(ConfigurationName)" "$(ProjectDir)Web.config" /Y/R
"'xcopy' is not recognized as an internal or external command."
I then changed my statement to:
C:\Windows\System32\xcopy "$(ProjectDir)config\Web.config.$(ConfigurationName)" "$(ProjectDir)Web.config" /Y/R
Tuesday, February 18, 2020
Getting Columns Headers without Result Data in SQL Server
SET FMTONLY ON
SET FMTONLY ON returns only metadata to the client. It can be used to test the format of the response without actually running the query. When this setting is ON the resultset only have headers of the results but no data. If resultset has Spatial Results, it will have the spatial results tab as well, however, no spatial data.
sample :-
Monday, February 17, 2020
SQL Server Profiler
What is an SQL Server Profiler?
An SQL server profiler is a tool for tracing, recreating, and troubleshooting problems in MS SQL Server, Microsoft’s Relational Database Management System (RDBMS). The profiler lets developers and Database Administrators (DBAs) create and handle traces and replay and analyze trace results
How it works
It works by giving DBAs and developers a high-level view of the operation of a system. Users create traces to capture data and monitor errors and other problems. They then use the profiler to store, retrieve, and view the results of many traces graphically for purposes of troubleshooting and repair. This function all happens on the client-side, meaning it uses resources on the same machine it’s monitoring.
Benefits
An SQL server profiler is a tool for tracing, recreating, and troubleshooting problems in MS SQL Server, Microsoft’s Relational Database Management System (RDBMS). The profiler lets developers and Database Administrators (DBAs) create and handle traces and replay and analyze trace results
How it works
It works by giving DBAs and developers a high-level view of the operation of a system. Users create traces to capture data and monitor errors and other problems. They then use the profiler to store, retrieve, and view the results of many traces graphically for purposes of troubleshooting and repair. This function all happens on the client-side, meaning it uses resources on the same machine it’s monitoring.
Benefits
- Clarity. It can reveal how an instance works when it’s interacting with a client.
- Troubleshoot problems. It can help zero in on trouble spots by allowing us to capture and replay key events. This function also helps with stress testing and identifying slowly executing queries.
- Allow non-administrator users to create traces securely. It can cater to the needs of DBAs, developers, database designers, business intelligence specialists, IT professionals, and even accountants.
- Compare activity to baselines. It lets users save trace data and compare it to newer data to spotlight new trouble spots.
- Capture traces for Transact-SQL, SSIS, and Analysis Services.
Thursday, February 6, 2020
SQL join: where clause vs. on clause
SELECT *
FROM Orders
LEFT JOIN OrderLines ON OrderLines.OrderID=Orders.ID
WHERE Orders.ID = 12345
and
SELECT *
FROM Orders
LEFT JOIN OrderLines ON OrderLines.OrderID=Orders.ID
AND Orders.ID = 12345
a. WHERE clause: After joining. Records will be filtered after join has taken place.
b. ON clause - Before joining. Records (from right table) will be filtered before joining
JavaScript — What’s the difference between Null & Undefined?
null is an assigned value. It means nothing.
undefined means a variable has been declared but not defined yet.
null is an object. undefined is of type undefined.
null !== undefined but null == undefined.
undefined means a variable has been declared but not defined yet.
null is an object. undefined is of type undefined.
null !== undefined but null == undefined.
Differences between Response.End() and Response.Flush()
Response.Flush
Forces all currently buffered output to be sent to the client. The Flush method can be called multiple times during request processing.
Response.End
Sends all currently buffered output to the client, stops execution of the page, and raises the EndRequest event.
You should try using this code if you are not doing any processing on the page after Response.Write and want to stop processing the page.
context.HttpContext.Response.Clear();
context.HttpContext.Response.Write(htmlString);
context.HttpContext.Response.Flush(); // send all buffered output to client
context.HttpContext.Response.End(); // response.end would work fine now.
Subscribe to:
Comments (Atom)
Change default Port on Next.js app
If any other app or process is running on port 3000 , you will get this error in your terminal Port 3000 is already in use. error Command f...
-
sample values in that Username column:- 1) <Name=test> 2) <Name=testKing> 3) <Name=King> Sql Query select...
-
xcopy "$(ProjectDir)config\Web.config.$(ConfigurationName)" "$(ProjectDir)Web.config" /Y/R "'xcopy' is n...
-
Right Click on Report Field, go to Format Object, Click on Number, Check the Suppress if Zero Field. Report will not show zero values. ...

