How to Debug WCF Service?
Sunday, December 30, 2012 Category : ASP.NET, C-sharp.NET 0
If that's the case, you can always modify the recycling condition settings of your application pools, so the process will remain alive for a longer time.
A free source of help.
Home > 2012
Sunday, December 30, 2012 Category : ASP.NET, C-sharp.NET 0
Thursday, December 27, 2012 Category : C-sharp.NET 0
Unknown Query Engine Error
Error in File C:\Users\ADMINI~1\AppData\Local\Temp\temp_4f6e51af-81ea-4f14-b0dd-f65decbb6e23 {30D198AB-EC2B-48F7-B979-EBEAF777E2C8}.rpt:
Unknown Query Engine Error
Solution :
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
Wednesday, December 19, 2012 Category : C-sharp.NET 0
[Serializable()]
[ToolboxBitmap(typeof(TextBox))]
public partial class NumericTextBox : TextBox
{
public NumericTextBox()
{
InitializeComponent();
//base.Version = "1.3"; // 2008-11-24
base.Multiline = false;
base.TextAlign = HorizontalAlignment.Right;
base.Text = "0";
System.Globalization.CultureInfo ci = System.Threading.Thread.CurrentThread.CurrentCulture;
m_decimalSeparator = ci.NumberFormat.CurrencyDecimalSeparator[0];
m_negativeSign = ci.NumberFormat.NegativeSign[0];
this.SetValueFormatStr();
this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Location = new System.Drawing.Point(0, 0);
//this.Name = "textBox1";
this.Size = new System.Drawing.Size(100, 24);
}
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
}
/**********************************************************/
#region member fields
private const int m_MaxDecimalLength = 10; // max dot length
private const int m_MaxValueLength = 27; // decimal can be 28 bits.
private const int WM_CHAR = 0x0102; // char key message
private const int WM_CUT = 0x0300; // mouse message in ContextMenu
private const int WM_COPY = 0x0301;
private const int WM_PASTE = 0x0302;
private const int WM_CLEAR = 0x0303;
private int m_decimalLength = 0;
private bool m_allowNegative = true;
private string m_valueFormatStr = string.Empty;
private char m_decimalSeparator = '.';
private char m_negativeSign = '-';
#endregion
#region disabled public properties
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
[DefaultValue(typeof(HorizontalAlignment), "Right")]
public new HorizontalAlignment TextAlign
{
get { return base.TextAlign; }
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new string[] Lines
{
get { return base.Lines; }
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new ImeMode ImeMode
{
get { return base.ImeMode; }
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new char PasswordChar
{
get { return base.PasswordChar; }
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new bool UseSystemPasswordChar
{
get { return base.UseSystemPasswordChar; }
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new bool Multiline
{
get { return base.Multiline; }
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new AutoCompleteStringCollection AutoCompleteCustomSource
{
get { return base.AutoCompleteCustomSource; }
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new AutoCompleteMode AutoCompleteMode
{
get { return base.AutoCompleteMode; }
set { base.AutoCompleteMode = value; }
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new AutoCompleteSource AutoCompleteSource
{
get { return base.AutoCompleteSource; }
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new CharacterCasing CharacterCasing
{
get { return base.CharacterCasing; }
}
#endregion
#region override public properties
[DefaultValue("0")]
public override string Text
{
get
{
return base.Text;
}
set
{
decimal val;
if (decimal.TryParse(value, out val))
{
base.Text = val.ToString(m_valueFormatStr);
}
else
{
base.Text = 0.ToString(m_valueFormatStr);
}
}
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override int MaxLength
{
get
{
return base.MaxLength;
}
}
#endregion
#region custom public properties
[Category("Custom")]
[Description("Set/Get dot length(0 is integer, 10 is maximum).")]
[DefaultValue(0)]
public int DecimalLength
{
get
{
return m_decimalLength;
}
set
{
if (m_decimalLength != value)
{
if (value < 0 || value > m_MaxDecimalLength)
{
m_decimalLength = 0;
}
else
{
m_decimalLength = value;
}
this.SetValueFormatStr();
base.Text = this.Value.ToString(m_valueFormatStr);
}
}
}
[Category("Custom")]
[Description("Get decimal value of textbox.")]
public decimal Value
{
get
{
decimal val;
if (decimal.TryParse(base.Text, out val))
{
return val;
}
return 0;
}
}
[Category("Custom")]
[Description("Get integer value of textbox.")]
public int IntValue
{
get
{
decimal val = this.Value;
return (int)val;
}
}
[Category("Custom")]
[Description("Number can be negative or not.")]
[DefaultValue(true)]
public bool AllowNegative
{
get { return m_allowNegative; }
set
{
if (m_allowNegative != value)
{
m_allowNegative = value;
}
}
}
#endregion
#region override events or methods
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_PASTE) // mouse paste
{
this.ClearSelection();
SendKeys.Send(Clipboard.GetText());
base.OnTextChanged(EventArgs.Empty);
}
else if (m.Msg == WM_COPY) // mouse copy
{
Clipboard.SetText(this.SelectedText);
}
else if (m.Msg == WM_CUT) // mouse cut or ctrl+x shortcut
{
Clipboard.SetText(this.SelectedText);
this.ClearSelection();
base.OnTextChanged(EventArgs.Empty);
}
else if (m.Msg == WM_CLEAR)
{
this.ClearSelection();
base.OnTextChanged(EventArgs.Empty);
}
else
{
base.WndProc(ref m);
}
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys)Shortcut.CtrlV)
{
this.ClearSelection();
string text = Clipboard.GetText();
// SendKeys.Send(text);
for (int k = 0; k < text.Length; k++) // can not use SendKeys.Send
{
SendCharKey(text[k]);
}
return true;
}
else if (keyData == (Keys)Shortcut.CtrlC)
{
Clipboard.SetText(this.SelectedText);
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (!this.ReadOnly)
{
if (e.KeyData == Keys.Delete || e.KeyData == Keys.Back)
{
if (this.SelectionLength > 0)
{
this.ClearSelection();
}
else
{
this.DeleteText(e.KeyData);
}
e.SuppressKeyPress = true; // does not transform event to KeyPress, but to KeyUp
}
}
}
/// <summary>
/// repostion SelectionStart, recalculate SelectedLength
/// </summary>
protected override void OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e);
if (this.ReadOnly)
{
return;
}
if (e.KeyChar == (char)13 || e.KeyChar == (char)3 || e.KeyChar == (char)22 || e.KeyChar == (char)24)
{
return;
}
if (m_decimalLength == 0 && e.KeyChar == m_decimalSeparator)
{
e.Handled = true;
return;
}
if (!m_allowNegative && e.KeyChar == m_negativeSign && base.Text.IndexOf(m_negativeSign) < 0)
{
e.Handled = true;
return;
}
if (!char.IsDigit(e.KeyChar) && e.KeyChar != m_negativeSign && e.KeyChar != m_decimalSeparator)
{
e.Handled = true;
return;
}
if (base.Text.Length >= m_MaxValueLength && e.KeyChar != m_negativeSign)
{
e.Handled = true;
return;
}
if (e.KeyChar == m_decimalSeparator || e.KeyChar == m_negativeSign) // will position after dot(.) or first
{
this.SelectionLength = 0;
}
else
{
this.ClearSelection();
}
bool isNegative = (base.Text[0] == m_negativeSign) ? true : false;
if (isNegative && this.SelectionStart == 0)
{
this.SelectionStart = 1;
}
if (e.KeyChar == m_negativeSign)
{
int selStart = this.SelectionStart;
if (!isNegative)
{
base.Text = m_negativeSign + base.Text;
this.SelectionStart = selStart + 1;
}
else
{
base.Text = base.Text.Substring(1, base.Text.Length - 1);
if (selStart >= 1)
{
this.SelectionStart = selStart - 1;
}
else
{
this.SelectionStart = 0;
}
}
e.Handled = true; // minus(-) has been handled
return;
}
int dotPos = base.Text.IndexOf(m_decimalSeparator) + 1;
if (e.KeyChar == m_decimalSeparator)
{
if (dotPos > 0)
{
this.SelectionStart = dotPos;
}
e.Handled = true; // dot has been handled
return;
}
if (base.Text == "0")
{
this.SelectionStart = 0;
this.SelectionLength = 1; // replace thre first char, ie. 0
}
else if (base.Text == m_negativeSign + "0")
{
this.SelectionStart = 1;
this.SelectionLength = 1; // replace thre first char, ie. 0
}
else if (m_decimalLength > 0)
{
if (base.Text[0] == '0' && dotPos == 2 && this.SelectionStart <= 1)
{
this.SelectionStart = 0;
this.SelectionLength = 1; // replace thre first char, ie. 0
}
else if (base.Text.Substring(0, 2) == m_negativeSign + "0" && dotPos == 3 && this.SelectionStart <= 2)
{
this.SelectionStart = 1;
this.SelectionLength = 1; // replace thre first char, ie. 0
}
else if (this.SelectionStart == dotPos + m_decimalLength)
{
e.Handled = true; // last position after text
}
else if (this.SelectionStart >= dotPos)
{
this.SelectionLength = 1;
}
else if (this.SelectionStart < dotPos - 1)
{
this.SelectionLength = 0;
}
}
}
/// <summary>
/// reformat the base.Text
/// </summary>
protected override void OnLeave(EventArgs e)
{
if (string.IsNullOrEmpty(base.Text))
{
base.Text = 0.ToString(m_valueFormatStr);
}
else
{
base.Text = this.Value.ToString(m_valueFormatStr);
}
base.OnLeave(e);
}
#endregion
#region custom private methods
private void SetValueFormatStr()
{
m_valueFormatStr = "F" + m_decimalLength.ToString();
}
private void SendCharKey(char c)
{
Message msg = new Message();
msg.HWnd = this.Handle;
msg.Msg = WM_CHAR;
msg.WParam = (IntPtr)c;
msg.LParam = IntPtr.Zero;
base.WndProc(ref msg);
}
/// <summary>
/// Delete operator will be changed to BackSpace in order to
/// uniformly handle the position of deleted digit.
/// </summary>
private void DeleteText(Keys key)
{
int selStart = this.SelectionStart; // base.Text will be delete at selStart - 1
if (key == Keys.Delete) // Delete key change to BackSpace key, adjust selStart value
{
selStart += 1; // adjust position for BackSpace
if (selStart > base.Text.Length) // text end
{
return;
}
if (this.IsSeparator(selStart - 1)) // next if delete dot(.) or thousands(;)
{
selStart++;
}
}
else // BackSpace key
{
if (selStart == 0) // first position
{
return;
}
if (this.IsSeparator(selStart - 1)) // char which will be delete is separator
{
selStart--;
}
}
if (selStart == 0 || selStart > base.Text.Length) // selStart - 1 no digig
{
return;
}
int dotPos = base.Text.IndexOf(m_decimalSeparator);
bool isNegative = (base.Text.IndexOf(m_negativeSign) >= 0) ? true : false;
if (selStart > dotPos && dotPos >= 0) // delete digit after dot(.)
{
base.Text = base.Text.Substring(0, selStart - 1) + base.Text.Substring(selStart, base.Text.Length - selStart) + "0";
base.SelectionStart = selStart - 1; // SelectionStart is unchanged
}
else // delete digit before dot(.)
{
if (selStart == 1 && isNegative) // delete 1st digit and Text is negative,ie. delete minus(-)
{
if (base.Text.Length == 1) // ie. base.Text is '-'
{
base.Text = "0";
}
else if (dotPos == 1) // -.* format
{
base.Text = "0" + base.Text.Substring(1, base.Text.Length - 1);
}
else
{
base.Text = base.Text.Substring(1, base.Text.Length - 1);
}
base.SelectionStart = 0;
}
else if (selStart == 1 && (dotPos == 1 || base.Text.Length == 1)) // delete 1st digit before dot(.) or Text.Length = 1
{
base.Text = "0" + base.Text.Substring(1, base.Text.Length - 1);
base.SelectionStart = 1;
}
else if (isNegative && selStart == 2 && base.Text.Length == 2) // -* format
{
base.Text = m_negativeSign + "0";
base.SelectionStart = 1;
}
else if (isNegative && selStart == 2 && dotPos == 2) // -*.* format
{
base.Text = m_negativeSign + "0" + base.Text.Substring(2, base.Text.Length - 2);
base.SelectionStart = 1;
}
else // selStart > 0
{
base.Text = base.Text.Substring(0, selStart - 1) + base.Text.Substring(selStart, base.Text.Length - selStart);
base.SelectionStart = selStart - 1;
}
}
}
/// <summary>
/// clear base.SelectedText
/// </summary>
private void ClearSelection()
{
if (this.SelectionLength == 0)
{
return;
}
if (this.SelectedText.Length == base.Text.Length)
{
base.Text = 0.ToString(m_valueFormatStr);
return;
}
int selLength = this.SelectedText.Length;
if (this.SelectedText.IndexOf(m_decimalSeparator) >= 0)
{
selLength--; // selected text contains dot(.), selected length minus 1
}
this.SelectionStart += this.SelectedText.Length; // after selected text
this.SelectionLength = 0;
for (int k = 1; k <= selLength; k++)
{
this.DeleteText(Keys.Back);
}
}
private bool IsSeparator(int index)
{
return this.IsSeparator(base.Text[index]);
}
private bool IsSeparator(char c)
{
if (c == m_decimalSeparator)
{
return true;
}
return false;
}
#endregion
/********************************************************/
Category : C-sharp.NET 0
public partial class VComboBox : ComboBox
{
public event System.ComponentModel.CancelEventHandler NotInList;
private bool _limitToList = true;
private bool _inEditMode = false;
public VComboBox() : base()
{
InitializeComponent();
this.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FormattingEnabled = true;
this.Location = new System.Drawing.Point(118, 329);
this.MaxDropDownItems = 10;
this.Name = "comboBox1";
this.Size = new System.Drawing.Size(197, 26);
}
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
}
[Category("Behavior")]
public bool LimitToList
{
get { return _limitToList; }
set { _limitToList = value; }
}
protected virtual void
OnNotInList(System.ComponentModel.CancelEventArgs e)
{
if (NotInList != null)
{
NotInList(this, e);
}
}
protected override void OnEnter(EventArgs e)
{
base.OnEnter(e);
this.DroppedDown = true;
}
protected override void OnLeave(EventArgs e)
{
base.OnLeave(e);
this.DroppedDown = false;
}
protected override void OnTextChanged(System.EventArgs e)
{
if (_inEditMode)
{
string input = Text;
int index = FindString(input);
if (index >= 0)
{
_inEditMode = false;
SelectedIndex = index;
_inEditMode = true;
Select(input.Length, Text.Length);
this.DroppedDown = true;
}
}
base.OnTextChanged(e);
}
protected override void
OnValidating(System.ComponentModel.CancelEventArgs e)
{
if (this.LimitToList)
{
int pos = this.FindStringExact(this.Text);
if (pos == -1)
{
OnNotInList(e);
}
else
{
this.SelectedIndex = pos;
}
}
base.OnValidating(e);
}
protected override void
OnKeyDown(System.Windows.Forms.KeyEventArgs e)
{
_inEditMode =
(e.KeyCode != Keys.Back && e.KeyCode != Keys.Delete);
base.OnKeyDown(e);
}
Friday, November 30, 2012 Category : ASP.NET 0
In Local PC
<system.web>
<httpHandlers>
<add verb="*" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</httpHandlers>
</system.web>
In Remote PC
<system.webServer>
<handlers>
<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/>
<add name="ChartImg" verb="*" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
</system.webServer>
<configuration>
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=200;dir=c:\TempImageFiles\;" />
</appSettings>
</configuration>
Here TempImageFiles is a folder in c drive of server pc. you need to just create it, nothing else . if face some permission related problem. allow iis to specific user to access this.
Monday, November 12, 2012 Category : ASP.NET 0
aspnet_regsql -ed -E -d School
The command above will enable the Cache dependency on the "School"
database. The next step is to enable the caching on the individual
table. You can do that by using the following line.aspnet_regsql -et -E -d School -t Users
The above line will enable the caching on the Users table which is contained in the School database.connectionString
in the connectionStrings
section and sqlCacheDependency
in the web.config file. Take a look at the code below:<connectionStrings>
<add name="ConnectionString"
connectionString="Server=localhost;Database=School;
Trusted_Connection=true"/>
</connectionStrings>
<system.web>
<caching>
<sqlCacheDependency pollTime="10000" enabled="true" >
<databases>
<add connectionStringName="ConnectionString" name="School"/>
</databases>
</sqlCacheDependency>
</caching>lt;/caching>
As, you have noticed that the sqlCacheDependency
have a pollTime
attribute which is set to "1000" milliseconds. This means that the
ASP.NET will check the database table for any changes every 10 seconds.
The database section of the <caching>
contains the connectionString
which is used to connect to the database.private void BindData()
{
// if null then fetch from the database
if (Cache["Users"] == null)
{
// Create the cache dependency
SqlCacheDependency dep = new SqlCacheDependency("School", "Users");
string connectionString = ConfigurationManager.ConnectionStrings[
"ConnectionString"].ConnectionString;
SqlConnection myConnection = new SqlConnection(connectionString);
SqlDataAdapter ad = new SqlDataAdapter("SELECT FirstName, LastName " +
"FROM Users", myConnection);
DataSet ds = new DataSet();
ad.Fill(ds);
// put in the cache object
Cache.Insert("Users", ds, dep);
}
gvUsers.DataSource = Cache["Users"] as DataSet;
gvUsers.DataBind();
}
The line SqlCacheDependency dep = new SqlCacheDependency("School", "Users");
is used to create the caching on the School database and Users table. In the beginning of the BindData
method I check that if the item is already in the Cache. If it is then I
simply return the item using caller by casting it from the Cache
object. If the item is not in the Cache then the data is fetched from
the database and inserted into the Cache object. The Cache will be
discarded anytime you make a change in the database table "Users". This
means that if you INSERT, DELETE, UPDATE any data in any row in the
Users table then the Cache will be considered obsolete and a copy of the
fresh data will be fetched from the database.Tuesday, October 30, 2012 Category : Jquery 0
<script type="text/javascript">
$(document).ready(function () {
var pathname = window.location.pathname;
var index = pathname.lastIndexOf("/");
var filename = pathname.substr(index + 1);
if (filename == 'Default.aspx' || filename == 'NewSalesUI.aspx' || filename == 'SalesVoid.aspx') {
$('a[href="' + filename + '"]').attr("class", "main current");
}
else {
index = 0;
index = pathname.lastIndexOf("Setup");
if (index > 0) {
var elements = $('span .settings');
if (elements != null && elements != NaN) {
var p = elements.parent().parent();
p.attr("class", "main current");
}
return;
}
index = 0;
index = pathname.lastIndexOf("Operation");
if (index > 0) {
var elements = $('span .operation');
if (elements != null && elements != NaN) {
var p = elements.parent().parent();
p.attr("class", "main current");
}
}
index = 0;
index = pathname.lastIndexOf("Account");
if (index > 0) {
var elements = $('span .newsletter');
if (elements != null && elements != NaN) {
var p = elements.parent().parent();
p.attr("class", "main current");
}
return;
}
index = 0;
index = pathname.lastIndexOf("Report");
if (index > 0) {
var elements = $('span .reports');
if (elements != null && elements != NaN) {
var p = elements.parent().parent();
p.attr("class", "main current");
}
return;
}
}
});
</script>
Category : ASP.NET, C-sharp.NET 0
Introduction:
Here I will explain how to solve the problem “The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).” when running web application using asp.net.
Description:
I created one web application and added some of script files in header section of page like this
<head id="head2" runat="server">
<title>Lightbox Page</title>
<link href="aspdotnetsuresh.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%= ResolveUrl("~/js/LightBox.js") %>"></script>
</head>
|
Server Error in 'ASP.Net' Application.
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.
|
<head id="head2" runat="server">
<title>Lightbox Page</title>
<link href="aspdotnetsuresh.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%# ResolveUrl("~/js/LightBox.js") %>"></script>
</head>
|
protected void Page_Load(object sender, EventArgs e)
{
Page.Header.DataBind();
}
|
Thursday, October 18, 2012 Category : ASP.NET, C-sharp.NET 0
ParameterField paramerterField = new ParameterField();
ParameterFields parameterFields = new ParameterFields();
ParameterDiscreteValue pdvReprint = new ParameterDiscreteValue();
private void setParameter()
{
string rep = "";
try
{
rep = Request.QueryString["Rep"].ToString();
}
catch (Exception ex)
{
rep = "";
}
if (rep != "")
{
paramerterField.ParameterFieldName = "@Reprint";
pdvReprint.Value = rep;
paramerterField.CurrentValues.Add(pdvReprint);
parameterFields.Add(paramerterField);
CrViewer.ParameterFieldInfo = parameterFields;
}
else
{
paramerterField.ParameterFieldName = "@Reprint";
pdvReprint.Value = "";
paramerterField.CurrentValues.Add(pdvReprint);
parameterFields.Add(paramerterField);
CrViewer.ParameterFieldInfo = parameterFields;
}
}
Wednesday, October 17, 2012 Category : ASP.NET 0
Use this course on you child page content place holder
<script language="javascript">
document.getElementById("setupmenu").className = "main current";
</script>
do not use in header contenet place holder , it will generate error.
OR
Using Jqery in Master page
<script type="text/javascript">
$(document).ready(function () {
var pathname = window.location.pathname;
var index = pathname.lastIndexOf("/");
var filename = pathname.substr(index + 1);
$('a[href="' + filename + '"]').attr("class", "main current");
});
</script>
Sunday, October 7, 2012 Category : SQL 0
Use a table valued function like this,
CREATE FUNCTION Splitfn(@String varchar(8000), @Delimiter char(1))
returns @temptable TABLE (items varchar(8000)) as begin
declare @idx int
declare @slice varchar(8000)
select @idx = 1
if len(@String)<1 or @String is null return
while @idx!= 0
begin
set @idx = charindex(@Delimiter,@String)
if @idx!=0
set @slice = left(@String,@idx - 1)
else
set @slice = @String
if(len(@slice)>0)
insert into @temptable(Items) values(@slice)
set @String = right(@String,len(@String) - @idx)
if len(@String) = 0 break
end return
end
and get your variable and use this function like this,
SELECT i.items FROM dbo.Splitfn(@a,'|') AS i
===============================================================================
Optional
use this function to generate a relation data with other table
create function getTeacherDepartmentSplit()
returns @tempTeacher table (TeacherID nvarchar(50),DepartmentID nvarchar(50))
as
begin
DECLARE @TeacherID nvarchar(50)
DECLARE @DepartmentIDs nvarchar(50)
declare dbCursor cursor for
SELECT dbo.Teacher.TeacherID, dbo.Teacher.DepartmentIDs FROM dbo.Teacher
open dbCursor
FETCH NEXT FROM dbCursor INTO @TeacherID,@DepartmentIDs
While @@FETCH_STATUS = 0
begin
insert into @tempTeacher (TeacherID,DepartmentID)
SELECT @TeacherID,i.items FROM dbo.Splitfn(@DepartmentIDs,',') AS i
FETCH NEXT FROM dbCursor INTO @TeacherID,@DepartmentIDs
end
close dbCursor
return
end
select T.TeacherID,T.DepartmentID from getTeacherDepartmentSplit() as T
Monday, August 27, 2012 Category : ASP.NET 0
var shopNmae = document.getElementById('<%=ddlShopName.ClientID %>');
if(shopNmae.options[shopNmae.selectedIndex].text == 'Select')
{
alert('Select Shop Name');
return;
}
Sunday, August 26, 2012 Category : ASP.NET, C-sharp.NET 0
Call Javascript from c# code.
here PrintTree() is a javascript method.
For Post Back Button Event :
ScriptManager.RegisterStartupScript(btnViewGraph, btnViewGraph.GetType(), "addScript", "PrintTree();", true);
public void showReportAjax(string pageUrl, string param, Type cType, Page oPage, Control ctrl) { ScriptManager.RegisterStartupScript(ctrl, typeof(string), "redirect", "window.open('" + pageUrl + param + "');", true); } public static void ShowMessage(string msg) { Page page = HttpContext.Current.Handler as Page; msg = msg.Replace("\r\n", " "); msg = msg.Replace("'", ""); ScriptManager.RegisterStartupScript(page, page.GetType(), "msgs", "ShowMessage('" + msg + "');", true); }
Here is a fix for fifa o9 registry
Download the bat file and put it on your game directroy. then double click to run
Click Here For Download
Monday, July 30, 2012 Category : ASP.NET 0
Tuesday, July 17, 2012 Category : ASP.NET 0
IN PARENT PAGE
IN C# CODE
protected void gvIndent_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes[
"onmouseover"] = "this.style.cursor='hand';this.style.textDecoration='underline';";
e.Row.Attributes[
"onmouseout"] = "this.style.textDecoration='none';";
e.Row.Attributes[
"onclick"] = ClientScript.GetPostBackClientHyperlink(this.gvIndent, "Select$" + e.Row.RowIndex);
e.Row.Attributes.Add(
"onclick", "openPopUp('" + DataBinder.Eval(e.Row.DataItem, "indent_no") + "');");
}
}
In Page Load Event
string updateValuesScript = @"function updateValues(popupValues)
{
document.getElementById('ctl00_PlaceHolderLeft_txtIndentNo').value = popupValues[0];
}";
this.ClientScript.RegisterStartupScript(Page.GetType(), "UpdateValues", updateValuesScript.ToString(), true);
IN ASPX
<script type="text/javascript">
function openPopUp(strUser) {
var popUrl = 'indent_status.aspx?Value='+strUser;
var name = 'popUp';
var appearence = 'dependent=yes,menubar=no,resizable=yes,' +
'status=no,toolbar=no,titlebar=no,' +
'left=100,top=80';
var openWindow = window.open(popUrl, name, appearence);
openWindow.focus();
}
</script>
IN CHILD ASPX PAGE
protected void Page_Load(object sender, EventArgs e)
{
string updateParentScript = @"function updateParentWindow(ides)
{
var ide=ides;
var arrayValues= new Array(ide);
window.opener.updateValues(arrayValues);
window.close();
}";
//document.getElementById('lblID.ClientID').value;
this.ClientScript.RegisterStartupScript(this.GetType(), "UpdateParentWindow", updateParentScript, true);
btnClose.Attributes.Add("onclick", "updateParentWindow(parameter value)");
}
Saturday, July 14, 2012 Category : C-sharp.NET 0
#region Converting Image To Byte Array
Use This.
<httpHandlers>
<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=11.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</httpHandlers>
OR
<httpHandlers>
<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</httpHandlers>
Tuesday, July 10, 2012 Category : ASP.NET 0
System.Web.HttpException: Request is not available in this context
use HttpContext.Current.Response instead of Response.Cookie[""] = ....
use this code in your child page
<%@ MasterType VirtualPath="~/MasterSite.Master" %>
Add this code in your Master Page
public void FeatureVisibility(bool value)
{
PanelFeaturePro.Visible = value;
}
Now in Child Page
use : Master.FeatureVisibility(false);
Monday, July 9, 2012 Category : SQL 0
DECLARE @Random INT;
DECLARE @Upper INT;
DECLARE @Lower INT
---- This will create a random number between 1 and 999
SET @Lower = 0 ---- The lowest random number
SET @Upper = (SELECT COUNT(ItemID) AS Expr1 FROM dbo.basicSetupItem) ---- The highest random number
SELECT @Random = ROUND(((@Upper - @Lower -1) * RAND() + @Lower), 0)
--SELECT @Random;
WITH paging AS
(
SELECT
ROW_NUMBER() OVER (order by ItemID) AS rowid, *
FROM vBasicSetupItem
)
select *
from paging
where rowid = @Random
Sunday, July 8, 2012 Category : SQL 0
declare @FROM int
declare @TO int
--set @offset = 2;
--set @limit = 5;
--declare @idxini int
--declare @idxfim int
--select @idxfim = @offset * @limit -- 2 * 5 = 10
--select @idxini = @idxfim - (@limit-1); -- 10 - (5-1) = 7
WITH paging AS
(
SELECT
ROW_NUMBER() OVER (order by ItemID) AS rowid, *
FROM vBasicSetupItem
)
select *
from paging
where rowid between @FROM and @TO
order by rowid;
Friday, July 6, 2012 Category : ASP.NET 0
<system.web>
<customErrors mode="On" defaultRedirect="UI/ErrorPage.aspx" redirectMode="ResponseRewrite"/>
</system.web>
protected void Page_Load(object sender, EventArgs e)
{
try
{
HttpContext ctx = HttpContext.Current;
Exception exception = ctx.Server.GetLastError();
string errorInfo =
"<br>Offending URL: " + ctx.Request.Url.ToString() +
"<br>Source: " + exception.Source +
"<br> <b> Message: " + exception.Message + "</b>" +
"<br>Stack trace: " + exception.StackTrace;
lblMsg.Text = errorInfo;
}
catch (Exception ex)
{
}
}
Thursday, July 5, 2012 Category : SQL 0
DECLARE @SQL nvarchar(2000)
SET @SQL = 'INSERT INTO ----------------------'
Exec sp_executesql @SQL
IF @@ROWCOUNT = 1
BEGIN
SET @SQL = 'UPDATE [BuyCentral] SET [BalQty]=[BalQty]-' + @SQty + ' , [SQty]=[SQty]+' + @SQty + ' Where [ItemID]=' +@ItemID + ''
Exec sp_executesql @SQL
END
[Here @@ROWCOUNT a builtin variable which store if a insert or update or delete statement execute successfully]
Tuesday, July 3, 2012 Category : SQL 0
CREATE PROCEDURE [dbo].[sp_BarcodePrint]
-- Add the parameters for the stored procedure here
@ChallanNo VARCHAR(256) -- filename for backup
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @QTY int
DECLARE @Barcode VARCHAR(256)
CREATE TABLE #temp (
ChalanNo VARCHAR(256),
QTY int,
ProductName VARCHAR(256),
BrandName VARCHAR(256),
LineName VARCHAR(256),
ModelName VARCHAR(256),
ColorName VARCHAR(256),
SizeName VARCHAR(256),
Barcode VARCHAR(256),
CostPrice VARCHAR(256),
SalesPrice VARCHAR(256),
VAT decimal,
Serial VARCHAR(256) )
DECLARE db_cursor CURSOR FOR
SELECT RChallan.QTY,basicSetupItem.Barcode
FROM RChallan INNER JOIN
basicSetupItem ON RChallan.ItemID = basicSetupItem.ItemID
WHERE (RChallan.ChalanNo = @ChallanNo)
DECLARE @Flag INT
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @QTY,@Barcode
WHILE @@FETCH_STATUS = 0
BEGIN
SET @Flag = 1
WHILE (@QTY >= @Flag)
BEGIN
INSERT INTO #temp (ChalanNo,QTY,ProductName,BrandName,LineName,ModelName,ColorName,SizeName,Barcode,CostPrice,SalesPrice,VAT,Serial)
SELECT RChallan.ChalanNo, RChallan.QTY, vBasicSetupItem.ProductName, vBasicSetupItem.BrandName, vBasicSetupItem.LineName, vBasicSetupItem.ModelName,
vBasicSetupItem.ColorName, vBasicSetupItem.SizeName, vBasicSetupItem.Barcode, vBasicSetupItem.CostPrice, vBasicSetupItem.SalesPrice,
vBasicSetupItem.VAT,@Flag
FROM RChallan INNER JOIN
vBasicSetupItem ON RChallan.ItemID = vBasicSetupItem.ItemID
WHERE (RChallan.ChalanNo = @ChallanNo) AND (vBasicSetupItem.Barcode =@Barcode)
SET @Flag = @Flag + 1
END
FETCH NEXT FROM db_cursor INTO @QTY,@Barcode
END
CLOSE db_cursor
DEALLOCATE db_cursor
select * from #temp
drop table #temp
END
Powered by Blogger | Theme mxs | Converted by LiteThemes.com