Search This Blog
Saturday, November 5, 2011
How to check that a page is valid using javascript.
<script type="text/javascript">
function ValidatePage() {
if (typeof (Page_ClientValidate) == 'function') {
Page_ClientValidate();
}
if (Page_IsValid) {
// do something
alert('Page is valid!');
}
else {
// do something else
alert('Page is not valid!');
}
}
</script>
Sunday, October 23, 2011
why does an AutocompleteExtender get refreshed at given interval?
Wednesday, October 5, 2011
how to use Sql Server Profiler
•We can do the following using SQL Server Profiler
◦Create a trace
◦Watch the trace results as the trace runs
◦Store the trace results in a table
◦Start, stop, pause, and modify the trace results as necessary
◦Replay the trace results
•Use SQL Server Profiler to monitor only the events in which you are interested
How To Start SQL Profiler
>In Sql Server 2000
Start | Run | profiler | OK
>In Sql Server 2005
Start | All Programs | Microsoft SQL Server 2005 | Performance Tools | SQL Server Profiler.
Saturday, October 1, 2011
Integer Displaying as Hexadecimal When Debugging in Visual Studio.
You need to debug a project, open up the watch window: Debug > Windows > Watch 1 then right click on an entry and untick 'hexidecimal display'
Thursday, September 29, 2011
How to use GridViewDataRow with html contents.
The GridView will show the data as it is in datatable.It means it will show the html content as it is.
For Example:
Your DataTable has html content "<Strong>Testing</Strong>" but gridview display same "<Strong>Testing</Strong>" instead of "Testing".
Solution:
Add the following code into gridView's Rowdatabound event.
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
foreach (TableCell cell in e.Row.Cells)
{
cell.Text = Server.HtmlDecode(cell.Text);
}
}
Tuesday, September 27, 2011
How to swap column value of a sql table.
insert into tmp values('a','1')
insert into tmp values('b','2')
insert into tmp values('v','3')
Select * from tmp
output
A B
a 1
b 2
v 3
Update #tmp Set A=B, B=A
Select * from tmp
swapped output
A B
1 a
2 b
3 v
Sunday, September 25, 2011
Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list
Solution:Register IIS with ASPNET4.0 as follows......
c:\windows\microsoft.net\framework\v4.0.30319>aspnet_regiis -i
Friday, August 19, 2011
External table is not in the expected format.
Using the following connection string seems to fix most problems.
public static string path = @"C:\src\RedirectApplication\RedirectApplication\301s.xlsx";
public static string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;HDR=Yes;IMEX=1;";
Print Using Javascript.
{
var display_setting="toolbar=yes,location=no,directories=yes,menubar=yes,";
display_setting+="scrollbars=yes,width=750, height=600, left=100, top=25";
var lbtnPrint = document.getElementById('ctl00_CPHVmanage_FvVendorBillEntry_lbtnPrint');
lbtnPrint.style.display = 'none';
var content_innerhtml = document.getElementById(tblId).innerHTML;
var document_print = window.open("","",display_setting);
//document_print.document.open();
document_print.document.write('<html><head><title>Vendor Bill </title></head>');
document_print.document.write('<body onLoad="self.print();self.close();" >');
document_print.document.write(content_innerhtml);
document_print.document.write('</body> //document_print.print();
document_print.document.close();
lbtnPrint.style.display = 'block';
return false;
}
HTML:
<table id="tbl_display" style="text-align:left;" width="100%" cellpadding="2" cellspacing="2" border="0">
<tr>
<td align="left">
<p> Thank you valuable user for signing up.</p>
<p> We think you’ve made a bold decision, and look forward to a productive meeting.</p>
<p> Please print out a copy of this invitation - it will serve as your boarding pass on this tour. </p>
<p> For additional information, you can email <a href="mailto:someone@someone.com">someone@someone.com</a> or call -
xxx-xxx-xxxx, xxx-xxx-xxx and look for Mr. Someone.</p>
</td>
</tr>
</table>
<input type="ctl00_CPHVmanage_FvVendorBillEntry_lbtnPrint" value="Print" onclick="tablePrint('tbl_display');">
Friday, August 12, 2011
Keyword 'this' is not valid in a static property, static method, or static field initialize.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ArnoldBaseModule
{
public class Message
{
public static string GetMessage(int ModuleId, int UserId, int AppId, int ConAppId, bool Successed, int indicator)
{
if (Successed)
{
this.GenerateMessage(ModuleId, UserId, AppId, ConAppId, Successed, indicator);
//Use below line without 'this' to call a methos instead of above............
GenerateMessage(ModuleId, UserId, AppId, ConAppId, Successed, indicator);
}
return "";
}
private static string GenerateMessage(int ModuleId, int UserId, int AppId, int ConAppId, bool Successed, int indicator)
{
return "";
}
}
}
SqlConnection.ConnectionTimeout Property.
Namespace: System.Data.SqlClient
Assembly: System.Data (in System.Data.dll)
Type: System.Int32
The time (in seconds) to wait for a connection to open. The default value is 15 seconds.
SqlCommand.CommandTimeout Property.
Type: System.Int32
The time in seconds to wait for the command to execute. The default is 30 seconds.
Saturday, August 6, 2011
How to show div on mousehover?
<script type="text/javascript">
function Show(id) {
var div1 = document.getElementById("MainContent_div1");
div1.style.display = "block";
var ev = window.event;
var x = ev.clientX;//mouse position from left
var y = ev.clientY;//mouse position from top
div1.style.left = x;
div1.style.top = y;
}
function Hide(id) {
var div1 = document.getElementById("MainContent_div1");
div1.style.display = "none";
}
</script>
html part
<span id="MainContent_lbl1" onmouseover="javascript:Show(this);">Test <div id="MainContent_div1" style="position: absolute; z-index: 999; display: none;">
<table bgcolor="blue">
<tr>
<td>
<input name="ctl00$MainContent$txt1" type="text" id="MainContent_txt1" />
</td>
</tr>
<tr>
<td>
<input name="ctl00$MainContent$TextBox1" type="text" id="MainContent_TextBox1" />
</td>
</tr>
<tr>
<td>
<input name="ctl00$MainContent$TextBox2" type="text" id="MainContent_TextBox2" />
</td>
</tr>
<tr>
<td>
<input name="ctl00$MainContent$TextBox3" type="text" id="MainContent_TextBox3" />
</td>
</tr>
<tr>
<td>
<input name="ctl00$MainContent$TextBox4" type="text" id="MainContent_TextBox4" />
</td>
</tr>
<tr>
<td>
<input type="submit" name="ctl00$MainContent$btn1" value="Close" onclick="javascript:Hide(this);return false;" id="MainContent_btn1" />
</td>
</tr>
</table>
</div>
Friday, August 5, 2011
How to use Container.DataItemIndex?
<Columns>
<asp:TemplateField HeaderText="Sr.No.">
<ItemTemplate>
<asp:Label ID="SrNo" runat="server" Text='<%# Container.DataItemIndex + 1 %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Saturday, July 30, 2011
The operation has timed out.
To resolve this problem set the web service timeout at runtime
as below....
SheetCuttingWebService.Service objWeb;
objWeb = new UserInterfaceLayer.SheetCuttingWebService.Service();
objWeb.Timeout = 3600000(mili seconds);
dsPlate = objWeb.GetPlates(origin_id, specification, length, width, thickness, do_number, heat_no, plate_no, drawing_no, certificate_no, percentage_free, balance_wt, order_by_column, user_id, plate_id, reqLengthFrom, reqLengthTo, reqWidthFrom, reqWidthTo, IsDiscarded);
Monday, July 11, 2011
Javascript keyCode
|
|
|
|
Wednesday, July 6, 2011
Sys.InvalidOperationException: Handler must be a function.
...
....
<form id="form1" runat="server">
<asp:ScriptManager ID="sm1" runat="server"></asp:ScriptManager>
<cc1:TabContainer runat="server" ID="tbcTabContainer" OnClientActiveTabChanged="ChangeTab()"></cc1:TabContainer>
</form> Above OnClientActiveTabChanged="ChangeTab()" is not valid. Solution: Change OnClientActiveTabChanged="ChangeTab()" to OnClientActiveTabChanged="ChangeTab"
AutoCompleteExtender with Animation
<ajaxToolkit:AutoCompleteExtender runat="server" BehaviorID="AutoCompleteEx"
ID="autoComplete1" TargetControlID="txtPayorName" ServicePath="~/Public/AutoCompleteService.asmx"
MinimumPrefixLength="1" CompletionInterval="1000" EnableCaching="true" CompletionSetCount="20"
ServiceMethod="GetPayorsList" CompletionListCssClass="autocompleteCompletionListElement"
CompletionListItemCssClass="autocompleteListItem" CompletionListHighlightedItemCssClass="autocompleteHighlightedListItem"
DelimiterCharacters="">
<Animations>
<OnShow>
<Sequence>
<OpacityAction Opacity='0' />
<HideAction Visible='true'/>
<Parallel Duration='.1'>
<FadeIn />
<Length PropertyKey='height' StartValue='0' EndValueScript='225' />
</Parallel>
</Sequence>
</OnShow>
<OnHide>
<Parallel Duration='.1'>
<FadeOut/>
<Length PropertyKey='height' StartValueScript='225' EndValue='0'/>
</Parallel>
</OnHide>
</Animations>
</ajaxToolkit:AutoCompleteExtender>
Tuesday, July 5, 2011
Excel System.Data.OleDb.OleDbException: No value given for one or more required parameter
Solution:
if your Excel connection string contains 'HDR=Yes' then valid columns would be in the first row of the specified Worksheet (or Range). Otherwise, (HDR=No) the column names default to F1, F2, F3, etc.
Saturday, June 25, 2011
how to configure httpruntime?
<system.web>
<httpRuntime useFullyQualifiedRedirectUrl="true|false"
maxRequestLength="size in kbytes"
executionTimeout="seconds"
minFreeThreads="number of threads"
minFreeLocalRequestFreeThreads="number of threads"
appRequestQueueLimit="number of requests"
versionHeader="version string"/>
</configuration>
</system.web>
HTML: What does ' mean?
Whenever we type an apostrophe(') the ecards(html) replaces it with '. So ' is the Html representation for apostrophe(').
For Example: Html will convert Rahul's into Rahul's.
Wednesday, June 15, 2011
How to Encode and Decode a QueryString using c#?
e.g the actual url is "http://192.168.45.48/encoding/encode.aspx?crdl1=esos.{€h579". This url has some special character "{€". If you want to encode this url do as
HttpUtility.UrlEncode("http://192.168.45.48/encoding/encode.aspx?crdl1=esos.{€h579")
output will come as "http://192.168.45.48/encoding/encode.aspx?crdl1=esos.%7B%E2%82%ACh579".
And you can decode this encoded url using following code:
HttpUtility.UrlDecode("http://192.168.45.48/encoding/encode.aspx?crdl1=esos.%7B%E2%82%ACh579")
the output will come as "http://192.168.45.48/encoding/encode.aspx?crdl1=esos.{€h579"
Tuesday, May 17, 2011
Cannot start service from the command line or a debugger. A Windows Service must first be installed (using installutil.exe) and then started with ...
1) Build your Windows Service Project in VS.NET to generate its exe.
2) Run the Visual Studio.NET 2003 Command Prompt; OR On the DOS prompt, go to C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 (Directory path may vary).
3) Use the following command to run your Windows Service. (Subsitute the items in [...] according to your local app.)
installutil C:\[YourAppPath]\[AppName]\[Debug Release]\[AppName].exe
system.componentmodel.win32exception: no mapping between account names and security ids was done
system.componentmodel.win32exception: no mapping between account names and security ids was done
To resolve this problem add the below line to the ProjectInstaller.cs file (in InitializeComponent)
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
Wednesday, March 30, 2011
sys.ArgumentTypeException object of type 'object' cannot be converted to type 'Number'
e.g
function Number() {
var evnt = window.event;
if (parseInt(evnt.keyCode) >= 48 && parseInt(evnt.keyCode) <= 57) {
evnt.keyCode = evnt.keyCode;
return true;
}
else {
evnt.keyCode = 8;
return false;
}
}
Above function Number() is the actually built-in function with some arguments but here it is used as a user defined function width no argument.
Note: Change the function name or give the appropriate arguments to the function to resolved the above error.
Wednesday, March 16, 2011
How to drop sql connection
GO
ALTER DATABASE database name
SET OFFLINE WITH ROLLBACK IMMEDIATE
ALTER DATABASE database name
SET ONLINE
Wednesday, March 2, 2011
Tuesday, January 18, 2011
How to import data from txt file to sql table
BULK
INSERT #tmp
FROM '\\192.168.2.25\c$\test.txt'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
select * from #tmp