Wednesday, November 24, 2010

Convert String to DateTime Value in SQL 2005

Try this for string to DateTime
BEGIN
Declare @DateTimeValue varchar(20)
SET @DateTimeValue = 'Sam20101201121212'

Declare @Name varchar(3), @DateValue char(8) , @TimeValue char(6)
SELECT @Name = substring(@DateTimeValue,1,3)


SELECT @DateValue = substring(@DateTimeValue,4,8)
SELECT @DateValue

SELECT @TimeValue = substring(@DateTimeValue,12, len(@DateTimeValue) - 1)
SELECT @TimeValue

SELECT @DateTimeValue = convert(varchar, convert(datetime, @DateValue), 111)

+ ' ' + substring(@TimeValue, 1, 2)

+ ':' + substring(@TimeValue, 3, 2)

+ ':' + substring(@TimeValue, 5, len(@TimeValue) - 1)

SELECT @DateTimeValue


END

Tuesday, November 23, 2010

Renaming Master Page Inherited Page Control Names Using VB on Render Event

Imports System.IO

Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
Dim _html As New StringWriter()
Dim _render As New HtmlTextWriter(_html)
MyBase.Render(_render)
Dim outPut, result As String
If (_html.ToString().Contains("input type=""hidden""")) Then ' Add < 'before ' input word
outPut = _html.ToString().Replace("name=""ctl00$PageMainContentHldr$", "name=""").Replace("id=""ctl00_PageMainContentHldr_", "id=""")
result = outPut.Replace("name=""btnSubmit", "name=""ctl00$PageMainContentHldr$btnSubmit""").Replace("id=""btnSubmit", "id=""ctl00_PageMainContentHldr_btnSubmit""")
writer.Write(result)
End If
'btnSubmit.RenderControl(writer)
End Sub

MCTS, MCPD Dumbs

Hi Dudes,
Here am posting URL where u can downlaod all the Latest Dumps for Microsoft MCTS, MCPD Exams

http://www.4shared.com/network/search.jsp?sortType=2&sortOrder=1&sortmode=2&searchName=70-547&searchmode=2&searchName=70-547&searchDescription=&searchExtention=&sizeCriteria=atleast&sizevalue=10&start=0



http://www.4shared.com/network/search.jsp?sortType=4&sortOrder=-1&sortmode=3&searchName=Framework&searchmode=3&searchName=Framework&searchDescription=&searchExtention=&specifySize=true&sizeCriteria=atleast&sizevalue=2&start=40


http://decrypters.org/index.php?name=Downloads&req=viewdownload&cid=5&orderby=dateA


"ALL THE BEST"



ReGards,
Suresh

Error Code - 12031

HI Dudes,
Got Screwed UP eah ? Here is the solution!

Here am Posting the URL for the Error Code - 12031 (have eaten my brain)
and its description as Follows

Sys.WebForms.PageRequestManagerServerErrorException:
An unknown error occurred while processing the request on the server.
The status code returned from the server was: 12031

I almost struggled more than 7hrs of search in Web, atlast i found the Solution here
http://siderite.blogspot.com/2007/08/aspnet-connection-to-server-has-been.html

**********************
Yesterday I was trying desperately to understand why my web site was crashing without any error, the only information I could get being that the connection to the server has been reset. I've spent hours trying to determine what was wrong. Apparently I needed a break, because today it took me a few minutes to realize what it was.

First of all, duh! If there are issues with the connection server, look into the Windows Application Event Log. But we'll get there.

The "error" appeared at any postback after I loaded a certain page, but only if that page displayed a minimum of data. Above that threshold I would get the server reset thing that you can see both in IE7 and FireFox2 in the animated GIF. Basically the error messages were:
FireFox
The connection was reset
The connection to the server was reset while the page was loading.
Internet Explorer
Internet Explorer cannot display the webpage
Internet connectivity has been lost.
The website is temporarily unavailable.
The Domain Name Server (DNS) is not reachable.
Ajax UpdatePanel
Server returned error 12031

So, today I realised I should look in the Application Event Log and this Web Event Warning was displayed (shortened it a bit):
Event code: 3004
Event message: Post size exceeded allowed limits.

Process information:
Process name: aspnet_wp.exe

Exception information:
Exception type: HttpException
Exception message: Maximum request length exceeded.

Stack trace: at System.Web.HttpRequest.GetEntireRawContent()
at System.Web.HttpRequest.FillInFormCollection()
at System.Web.HttpRequest.get_Form()
at System.Web.HttpRequest.get_HasForm()
at System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull)
at System.Web.UI.Page.DeterminePostBackMode()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

It turns out I was putting a lot of data into the ViewState, which, as you know, is saved as a HiddenField (a.k.a. hidden html input) and the size of it exceeded the set up maximum POST size.

Solutions:
A. Add this code to your page: (NET 2.0)

protected override PageStatePersister PageStatePersister
{
get
{
//return base.PageStatePersister;
return new SessionPageStatePersister(this);
}
}



This should put your ViewState into the Session, rather than in the page. This solves some other issues as well, obviously.

B. Increase the maximum Request limit (default is 4Mb)
- In the Machine.config file, change the maxRequestLength attribute of the configuration section to a larger value. This change affects the whole computer.
- In the Web.config file, override the value of maxRequestLength for the application. For example, the following entry in Web.config allows files that are less than or equal to 8 megabytes (MB) to be uploaded:


This is an exact quote from the Microsoft support page.

That's it, folks!

Update:

The maxRequestLength maximum value is 2097151, that is less than 2.1Gb. No file that exceeds this size can be uploaded through the default upload mechanism.
**********************


Kudos to Siderite

Set Focus on TextBox in Ajax Modal Popup

Hi Guys,
Use this JS function to set Focus on Modal TextBox

function pageLoad()

{
var popupGroup = $find('ctl00_mdlSelectGroupForEdit'); //ModalPopupExtender Behviour ID
if (popupGroup != null)
popupGroup.add_shown(SetGroupFocus); // It will Fire while u clicking Control to show modal

}

function SetGroupFocus()
{
$get('<%= txtSearchPopupGroupName.ClientID %>').focus();// Set Focus on TextBox.

}
Hope this Solve your Problem,
Thanks,
SuresH

Deploying .Net Application in Windows Server 2003

In order to take a more proactive stance against malicious users and attackers, IIS is not installed on members of the Microsoft® Windows® Server 2003 family by default. Furthermore, when you initially install IIS, the service is installed in a highly secure and "locked" mode. By default, IIS serves only static content — meaning features like ASP, ASP.NET, Server-Side Includes, WebDAV publishing, and FrontPage® Server Extensions do not work unless enabled. If you do not enable this functionality after installing IIS, IIS returns a 404 error.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i

Use this command to install the aspnet in iis once you done with this steps

To enable and disable a Web service extension

1. In IIS Manager, expand the local computer, and then click Web Service Extensions.
2. In the details pane, click the Web Service Extension that you want to enable or disable.
3. To enable a disabled Web service extension, click Allow.
4. To disable an enabled Web service extension, click Prohibit.
5. Click OK.

Courtesy,

http://www.microsoft.com/technet

Handling GridView Child controls Validation Using JS

Below JS Used for Validating the ChildControls used in a Gridview without Paging

1. Checks atleast one checkbox must be selected
2. If checkbox selected for a row then DropDown must be selected.
3. Validating the textbox for whole Numbers and Decimal Digits validation (both functions not included here)

NOTE : since the requirement doesnt need the Paging and Gridview results ll not exceed 20 records so pagin is not handled here!

function funcCheckRowSelect() {
if (funcCheckDate()) {

var grdElement = document.getElementById('<%=grdStudentHeaderDetails.ClientID%>');
var Inputs = grdElement.getElementsByTagName("input");
var TargetChildControl = "StudentId";
var nmbr = 0;
var tmpChk;
//validate checkBox select - Start
for (i = 1; i < Inputs.length - 1; i++) {
if (Inputs[i].type == 'checkbox' && Inputs[i].id.indexOf(TargetChildControl, 0) >= 0) {
alert(Inputs[i].id);
tmpChk = Inputs[i].id;
if (Inputs[i].checked) {
nmbr = i;
break;
}
}
}
if (nmbr == 0) {
alert('Please select atleast one checkbox to save');
alert(document.getElementById(tmpChk));
return false;
}
//validate checkBox select - End
if (grdElement != null) {
for (k = 2; k <= grdElement.rows.length; k++) {
if (k < 10) {
var ctl = "ctl" + "0" + k;
}
else {
var ctl = "ctl" + k;
}
//alert(ctl);
var chkStudentId = document.getElementById('grdStudentHeaderDetails_' + ctl + '_StudentId');
if (chkStudentId != null) {
if (chkStudentId.checked) {
var drp = document.getElementById('grdStudentHeaderDetails_' + ctl + '_ddlOverAllRating');
if (drp != null) {
if (drp.selectedIndex == 0) {
alert('Please Select OverAll Rating to Save');
drp.focus();
return false;
}
}
var t1CorrectAns = document.getElementById('grdStudentHeaderDetails_' + ctl + '_txtTest1CorrAns');
var t1WrongAns = document.getElementById('grdStudentHeaderDetails_' + ctl + '_txtTest1WrongAns');
var t1Marks = document.getElementById('grdStudentHeaderDetails_' + ctl + '_txtTest1Marks');
var t2CorrectAns = document.getElementById('grdStudentHeaderDetails_' + ctl + '_txtTest2CorrAns');
var t2WrongAns = document.getElementById('grdStudentHeaderDetails_' + ctl + '_txtTest2WrongAns');
var t2Marks = document.getElementById('grdStudentHeaderDetails_' + ctl + '_txtTest2Marks');

if (AllowOnlyWholeNumber(t1CorrectAns) && AllowOnlyWholeNumber(t1WrongAns)
&& check_decimal(5, 1, t1Marks.value, 't1Marks') && AllowOnlyWholeNumber(t2CorrectAns)
&& AllowOnlyWholeNumber(t2WrongAns) && check_decimal(5, 1, t2Marks.value, 't2Marks')) {
return true;
}
else {
return false;
}
}
}
}
}
}
}