Friday, 20 July 2012

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

First Method
Remove JavaScript from the header section of page and add it to body of the page and run your application it will work for you.
Second Method
Replace the code block with <%# instead of <%=
<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>
After replace code block with <%# instead of <%= add following code in page load

protected void Page_Load(object sender, EventArgs e)
{
Page.Header.DataBind();    
}


Third Method
Add the Placeholder in header and body part of the Master page.

<head id="head2" runat="server">
<title>Lightbox Page</title>
 <asp:PlaceHolder ID="PlaceHolderHeader" runat="server">
<link href="aspdotnetsuresh.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%# ResolveUrl("~/js/LightBox.js") %>"></script>
 </asp:PlaceHolder>
</head>
 <body class="body">
    <form id="form1" runat="server">

    <asp:PlaceHolder ID="PlaceHolder1" runat="server">
           ---- past here all code
   </asp:PlaceHolder>
</form>
</body>


Tuesday, 17 July 2012

How to create Table-valued functions in sql


create FUNCTION [dbo].[fnTableType]   
(    
 @userID int
)   
RETURNS @UserNetworks TABLE    
(   
 [userID] [int],   
 [title] [nvarchar](512),
 [created] [datetime] ,   
 [modified] [datetime] ,
 [active] [bit]
)   
AS   
BEGIN   

 Insert @UserNetworks      
 Select  N.userID, UNM.title, N.created,N.modified,N.active from dbo.tblUser N
        inner join dbo.tblUserMembership UNM  on UNM.userId = N.UserID     
     where unm.userID = @userID
Return    
END   

OR

create FUNCTION [dbo].funTableType   
( @UserID int )   
RETURNS TABLE    
AS   
RETURN    
(Select * from dbo.tblUsers where active =1  and userID =  @UserID )