Monday, July 2, 2012

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).


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.

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

<head runat="server">
<title>Untitled Page</title>
<script type = "text/javascript">
function GetValue()
{
var txt = document.getElementById("<%=TextBox1.ClientID%>");
alert(txt.value);
}
</script>
</head>
Solution
Remove the part which has server tags and place it somewhere else if you want to add dynamic controls from code behind
I removed my JavaScript from the head section of page and added it to the body of the page and got it working

Saturday, July 23, 2011

Function to Split Multi-valued Parameters

CREATE FUNCTION [dbo].[SplitMultivaluedString] 
( 
   @DelimittedString [varchar](max), 
   @Delimiter [varchar](1) 
) 
RETURNS @Table Table (Value [varchar](100)) 
BEGIN 
   DECLARE @sTemp [varchar](max) 
   SET @sTemp = ISNULL(@DelimittedString,'') 
                + @Delimiter 
   WHILE LEN(@sTemp) > 0 
   BEGIN 
      INSERT INTO @Table 
      SELECT SubString(@sTemp,1,
             CharIndex(@Delimiter,@sTemp)-1) 
      
      SET @sTemp = RIGHT(@sTemp,
        LEN(@sTemp)-CharIndex(@Delimiter,@sTemp)) 
   END 
   RETURN 
END 
GO 

Source : sql-bi-dev

Friday, July 30, 2010

SQL Server Date Formats

There are several date formats available in the SQL like the following few formats
  • mm/dd/yy
  • mm/dd/yyyy
  • dd.mon.yyy
for complete list of the SQL date fromats use the this link Date Formats.

Wednesday, July 21, 2010

Download .dll or .exe files from IIS server.

If try to download he exe or dll file from the IIS server, you will get 404 file error. But this is incorrect settings in the IIS.

Why:
IIS Manager >> Website/VD >> Properties >> Home Directory >> Application Settings

Execute permissions set to "Scripts and Executables" in IIS.
 
Resolution:
IIS Manager >> Website/VD >> Properties >> Home Directory >> Application Settings

Set Execute permissions to "Scripts only" in IIS.

Friday, June 18, 2010

Microsoft Cursor Engine error '80004005'

When you are trying to retirve data from oracle database from classic ASP. You will get the bellow error.

Microsoft Cursor Engine error '80004005'
Data provider or other service returned an E_FAIL status.
/localhost/file.asp, line 68


For this you need to add NVL function for the null value column