Problem
Need to auto tab to the next form field when the maximum number of entered characters is reached.
Solution
Assigned [maxlenght] attribute and [autotab] class to each field you want to auto tab. Add the following code to $(document).ready event:
$('.autotab').keydown(function(event) {
//save previously entered value prior to keyup event
$(this).attr('prevValue', $(this).val());
});
$('.autotab').keyup(function(event) {
var newValue = $(this).val();
//see if the textbox had its value changed
if ($(this).attr('prevValue') != newValue) {
//see if the number of entered characters is equal or greater
//than the allowable maxlength
if (newValue.length >= $(this).attr('maxlength')) {
//set focus on the next field with autotab class
$(this).next('.autotab').focus();
}
//save newly entered value for the next execution of this event
$(this).attr('prevValue', newValue)
}
});
Hopefully, my comments in the above code is enough to understand how it works.
Problem
You receive “TruncationException: Trying to convert return value or output parameter of size XXX bytes to a T-SQL type with a smaller size limit of 8000 bytes” error while trying to execute CLR stored procedure in SQL Server 2008.
Explanation
CLR stored procedure is trying to return via output parameter string that exceeds 8000 bytes. Declaring output parameter as nvarchar(MAX) is not enough to overcome 8000 bytes limit.
Solution
In order to return strings via CLR procedures that are more than 8000 bytes you need to apply a special attribute called SqlFacet(MaxSize) to the output parameter.
Example in VB.NET:
Public Shared Sub MySP(<SqlFacet(MaxSize:=-1)> ByRef ret As SqlString)
Example in C#:
public static SqlString MySP([param: SqlFacet(MaxSize=-1)] SqlString ret)
Problem
My.Settings.YourSettingName is a read only property for application scope configuration
Explanation
By design you can’t modify application scope configuration settings, e.g. My.Settings.Setting1 is always read-only.
Solution
You can change the scope of the setting from Application to User, but then the setting will be stored in user.config instead of app.config
Another solution is to access application configuration file directly via System.Configuration.Configuration class. Here a small sample that updates LastDownloadDate configuration setting inside applicationSettings/APP.My.MySettings section:
Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
Dim sec As ClientSettingsSection = config.GetSection("applicationSettings/APP.My.MySettings")
sec.Settings.Get("LastDownloadDate").Value.ValueXml.InnerXml = Now.ToString
sec.SectionInformation.ForceSave = True
config.Save(ConfigurationSaveMode.Modified)
Problem
You receive “Cannot get IIS pickup directory” error while trying to send email via System.Net.Mail namespace in ASP.NET.
Explanation
User account under which the ASP.NET code is being executed doesn’t have access to the SMTP configuration path in IIS metabase.
Solution
- Find out under what domain/user account your ASP.NET application is running
- Download MetaAcl tool from here
- Run the following command:cscript Metaacl.vbs “IIS://localhost/SMTPsvc” your_domain\your_username RE
The above steps will give your_domain\your_username Read & Enumerate permissions in IIS metabase on SMTPsvc branch.