Posted by Ramani Sandeep on February 26, 2009
In almost all the web projects, we require a multiline TextBox control. It was annoying to find that maxLength property doesn’t work on multiline textboxes.
There are various ways to solve this issue, here i am using javascript to restrict user once he reach maxlimit.
<script type=”text/javascript” language=”javascript”>
function validatelimit(obj, maxchar)
{
if(this.id) obj = this;
var remaningChar = maxchar – obj.value.length;
document.getElementById(‘<%= Label1.ClientID %>’).innerHTML = remaningChar;
if( remaningChar <= 0)
{
obj.value = obj.value.substring(maxchar,0);
return false;
}
else
{return true;}
}
</script>
<asp:TextBox ID=”TextBox1″ runat=”server” TextMode=”MultiLine” onkeyup=”return validatelimit(this,500)” Height=”400px”></asp:TextBox>
<asp:Label ID=”Label1″ runat=”server” Text=”500″></asp:Label>
Other useful links :
http://forums.asp.net/t/1251514.aspx
Hope this will Help u.
Posted in JavaScript | Tagged: maxlength for multiline textbox, MaxLength ignored in multiline textbox | Leave a Comment »
Posted by Ramani Sandeep on February 16, 2009
Hi,
U can use app settings in aspx similar to connectionstrings in webconfig file
In your web config file
<appSettings>
<add key ="myKey" value ="myValue"/>
</appSettings>
In your aspx file
<asp:TextBox ID = "txtBox1" runat = "server" Text = "<%$appSettings:myKey %>" />
Similarly you can access appsettings values in javascript like this:
var my1 = ‘<%=ConfigurationManager.AppSettings["myKey"].ToString() %>’;
alert(my1);
Hope it helps
Posted in ASP.NET, JavaScript | Tagged: How to get appSetting values in .aspx file, Read Configuration Settings of Web.config using aspx page, Read Configuration Settings of Web.config using Javascript | Leave a Comment »
Posted by Ramani Sandeep on February 13, 2009
Stops the message that shows the count of the number of rows affected by a Transact-SQL statement or stored procedure from being returned as part of the result set.
syntax:
SET NOCOUNT { ON | OFF }
When SET NOCOUNT is ON, the count is not returned. When SET NOCOUNT is OFF, the count is returned.
The @@ROWCOUNT function is updated even when SET NOCOUNT is ON.
SET NOCOUNT ON prevents the sending of DONE_IN_PROC messages to the client for each statement in a stored procedure. For stored procedures that contain several statements that do not return much actual data, or for procedures that contain Transact-SQL loops, setting SET NOCOUNT to ON can provide a significant performance boost, because network traffic is greatly reduced.
The setting specified by SET NOCOUNT is in effect at execute or run time and not at parse time.
The following example prevents the message about the number of rows affected from being displayed.
USE AdventureWorks;
GO
SET NOCOUNT OFF;
GO
– Display the count message.
SELECT TOP(5)LastName
FROM Person.Contact
WHERE LastName LIKE ‘A%’;
GO
– SET NOCOUNT to ON to no longer display the count message.
SET NOCOUNT ON;
GO
SELECT TOP(5) LastName
FROM Person.Contact
WHERE LastName LIKE ‘A%’;
GO
– Reset SET NOCOUNT to OFF
SET NOCOUNT OFF;
GO
Posted in SQL Server | Tagged: SET NOCOUNT | Leave a Comment »
Posted by Ramani Sandeep on February 13, 2009
Returns the number of rows affected by the last statement. If the number of rows is more than 2 billion, use ROWCOUNT_BIG.
Transact-SQL statements can set the value in @@ROWCOUNT in the following ways:
* Set @@ROWCOUNT to the number of rows affected or read. Rows may or may not be sent to the client.
* Preserve @@ROWCOUNT from the previous statement execution.
* Reset @@ROWCOUNT to 0 but do not return the value to the client.
Statements that make a simple assignment always set the @@ROWCOUNT value to 1. No rows are sent to the client. Examples of these statements are: SET @local_variable, RETURN, READTEXT, and select without query statements such as SELECT GETDATE() or SELECT ‘Generic Text’.
Statements that make an assignment in a query or use RETURN in a query set the @@ROWCOUNT value to the number of rows affected or read by the query, for example: SELECT @local_variable = c1 FROM t1.
Data manipulation language (DML) statements set the @@ROWCOUNT value to the number of rows affected by the query and return that value to the client. The DML statements may not send any rows to the client.
DECLARE CURSOR and FETCH set the @@ROWCOUNT value to 1.
EXECUTE statements preserve the previous @@ROWCOUNT.
Statements such as USE, SET <option>, DEALLOCATE CURSOR, CLOSE CURSOR, BEGIN TRANSACTION or COMMIT TRANSACTION reset the ROWCOUNT value to 0.
EXAMPLE :
The following example executes an UPDATE statement and uses @@ROWCOUNT to detect if any rows were changed.
USE AdventureWorks;
GO
UPDATE HumanResources.Employee
SET Title = N’Executive’
WHERE NationalIDNumber = 123456789
IF @@ROWCOUNT = 0
PRINT ‘Warning: No rows were updated’;
GO
Posted in SQL Server | Tagged: @@RowCount | Leave a Comment »