Friday, January 15, 2010

CollapsiblePanelExtender basic animations

Here is some basic animation one can associate with the collapsible panel control -

<%--

<cc1:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server"
TargetControlID="Panel1"
CollapsedSize="0"
Collapsed="True"
AutoCollapse="False"
AutoExpand="False"
ScrollContents="True"
ExpandControlID="lblPanel1"
CollapseControlID="lblPanel1"
CollapsedText="Show Details..."
ImageControlID="imgDraft"
ExpandedText="Hide Details"
CollapsedImage="~/Images/collapse.gif"
ExpandedImage="~/Images/expand.gif"
ExpandDirection="Vertical"
/>

<cc1:AnimationExtender ID="AnimationPanel" runat="server" TargetControlID="lblPanel1" >
<Animations>
<OnClick>
<Sequence>
<EnableAction Enabled="false" />
<FadeOut AnimationTarget="Panel1"
Duration=".2" ></FadeOut>
<FadeIn AnimationTarget="Panel1"
Duration=".1" ></FadeIn>
<EnableAction Enabled="true" />
</Sequence>
</OnClick>
</Animations>
</cc1:AnimationExtender>
--%>


By using the AnimationTarget property of animation extender , i have associated only the panel to animate, so u do not have to give CollapsiblePanelExtender  for the TargetControlID ,doing so will will trigger the animation whenever and where ever you click on the CollapsiblePanelExtender control

Thursday, January 14, 2010

Session loss using AJAX

It sounded strange to me .... but the problem is a prevailing one. Your pages without AJAX works fine while the ones with AJAX doesn't and tend to lose their sessions without giving me errors. In my case I am the admin of a site and can login into anyone's account. I introduced AJAX toolkit for the first time, and while i tried to impersonate as someone else and issued a postback on ajax toolkit containing pages, it reverted me back to my original ID. Tried to find the solution to it, went through various forums but to no avail. Finally i realised that the application is going to the page where i have set the sessions for logging in (in my case i have a login page which is invisible to the user and picks up the credentials automatically from the intranet account)
So went to INETMGR and the properties of my default wesite , then to the tab documents.There i removed the non-important pages and added a single page. It worked for me , might for you, or probably its a specific case. But do give it a shot if u don't find the solution elsewhere.

TabContainer Animation on tab change

The AJAX animation extender when applied on Tabcontainer on "onclick" event produces some good results, but the problem arises when you click anywhere on the tab and the animation is fired which you dont want to happen. You just want the animation to fire at tab change.

Solution = Found some good code for it , tweaked it as per the requirements. Here is it -

<%--

<cc1:TabContainer ID="TabContainer1" runat="server" EnableViewState ="true" OnClientActiveTabChanged = "ActiveTabChanged" >

   <cc1:TabPanel ID = "panel1" HeaderText = "panel1" runat ="server" Enabled ="true" >
       <ContentTemplate>
             --Your Content
       </ContentTemplate>
    </cc1:TabPanel>

   <cc1:TabPanel ID = "panel2" HeaderText = "panel2" runat ="server">
       <ContentTemplate>
            --Your Content
       </ContentTemplate>
    </cc1:TabPanel>

    <cc1:TabPanel ID = "panel3" HeaderText = "panel3" runat ="server" Width = "500px" >
       <ContentTemplate>
            --Your Content
       </ContentTemplate>
    </cc1:TabPanel>

</cc1:TabContainer>

<script type="text/javascript">

function ActiveTabChanged(sender, e)
{
       var Tab = $get('<%=TabContainer1.ClientID%>'); }
       AnimateTab(Tab );
}
var HighlightAnimations = {};

function AnimateTab(el)
{
     if (HighlightAnimations[el.uniqueID] == null)
       {
          HighlightAnimations[el.uniqueID] = AjaxControlToolkit.Animation.createAnimation({
          AnimationName : "FadeOut",
          duration : 0.5,
          AnimationName : "FadeIn",
          duration : 0.5
}, el);
}

HighlightAnimations[el.uniqueID].stop();
HighlightAnimations[el.uniqueID].play();
}
</script>

--%>

Tuesday, January 5, 2010

Cannot access a closed file - file upload asp.net

REQUIRMENT - Need to upload a file after confirmation (ok-cancel) popup.

FIGHT -1 - The posted file from file upload control is removed as soon as the page is posted back.

SOLUTION - Save the posted file in a session as u press the upload document button you created, something like this -
        protected void btnUploadDocument_Click(object sender, EventArgs e)

                 {
                       Session["UploadFile"] = FileUploadControl.PostedFile;
                        //pop up code
                  }
Then the confirmation pop-up props up. On selecting 'OK' cast the session as HttpPostedFile , something like this -
                (HttpPostedFile)Session["UploadFile"]
Use this to upload the document.

FIGHT -2 -   Error - Cannot access Closed File

SOLUTION-  maxRequestLength, an attribute which governs the size of file being uploaded might have not been updated.
By default it is 4 mb. to increase it , < httpRuntime maxRequestLength="20000" /> within the
tag in the web.config (put the value as required)
The problem might still persist , the root lies in requestLengthDiskThreshold attribute
update the above mentioned tag to -

< httpRuntime maxRequestLength="20000" requestLengthDiskThreshold="9000"/ >


(For more info on the two attribures , go to - http://msdn.microsoft.com/en-us/library/e1f13641.aspx)

Tuesday, November 10, 2009

Unable to start debugging on the web server. The web server is not configured correctly (asp .net)

Scratched the whole day for this. Hope it would help someone. Here is the problem , solution and some useful links :

PROBLEM -

Site is deployed on QA server or production. One fine morning this error flashes on the site. The whole world comes down crashing at you. Now you try debugging it in your local machine but to no avail. The build is successful but it doesnt run giving a big dialog box with some blah blah error.
PROBABLE CAUSES AND SOLUTION-

1. IIS picks the .net framework version to run the application. If somehow frame work is installed prior to IIS , then IIS and framework linking is ruptured. You need to re-link them.
Solution - go to cmd prompt or VS command prompt ,copy and paste the following :
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -i
This relinks the iis and framework ......& Bingo !! it will work
2. Some freaking updates are installed on your workstation - either Symantec Endpoint Protection or some Windows update. So when tou try to run the mentioned command u receive an error.
Solution - Uninstall the Updates and run the command again.
3. Some valuable information can be found on the link
http://geekswithblogs.net/TimH/archive/2006/05/29/80002.aspx where a lot of troubled souls are combating with the problem .You will definitely find a solution if the abovementioned solutions didnt help.
4. If none helps , reinstall the frameworks and IIS . Now install IIS first then the frameworks.
5. Still persisting ......... Just pray......
O' Lord Help Me!! :)

Concatenate values in multiple columns into a single cell (SQL server 2005 and Oracle)

There are many instanc es wherein one is required to club values from different columns and rows into a condensed 1-cell format. Lets take an example:
Table - Tab_Emp :
NAME EMPLOYEE_CODE DESIGNATION
Ron 1 E
Paul 2 S
Maria 3 M
Rosy 4 R
The intended result is :
UNIFIED_INFORMATION
Name : Ron Code:1 Designation:E Name : Paul Code:2 Designation:S Name : Maria Code:3 Designation:M Name : Rosy Code:4 Designation:R

In SQL server 2005, we can create a cursor which reads through the table Tab_Emp and does the job for you. i have created a user defined function to do the same :

CREATE FUNCTION [Unify_Records]
RETURNS VARCHAR(8000)
AS
BEGIN --1
DECLARE @name VARCHAR(100)
DECLARE @code VARCHAR(100)
DECLARE @desig VARCHAR(100)
DECLARE @oneCELL varchar(8000)
SET @oneCELL = ''
Declare UNIFY_CURSOR Cursor For
SELECT * FROM Tab_Emp
BEGIN --2
OPEN UNIFY_CURSOR;
FETCH NEXT FROM UNIFY_CURSOR INTO @name,@code,@desig
WHILE (@@FETCH_STATUS = 0)
BEGIN -- 3
SET @oneCELL = @oneCELL +'NAME: '+ @name+', Code: '+ @code +', Desig: '+ @desig +''
FETCH NEXT FROM UNIFY_CURSOR INTO @name,@code,@desig
END --3
END --2
CLOSE UNIFY_CURSOR
DEALLOCATE UNIFY_CURSOR
return @oneCELL
END --1



  • For ORACLE , here is the generalised code :
    SELECT [Column1],
    SUBSTR(MAX(REPLACE(SYS_CONNECT_BY_PATH([Column2], '/'),'/','')),2) Concatenated_String
    FROM (select A.*,
    row_number() OVER (Partition by [Column1] order by [Column1]) ROW#
    from [Table_Name] A where [Column1] = ‘Ron’
    )
    START WITH ROW#=1
    CONNECT BY PRIOR [Column1]=[Column1] AND PRIOR row# = row# -1
    GROUP BY [Column1]
    Here all the values in [Column2] pertaining to [Column1] will be concatenated and the end result will be:
    [Column1]
    ∑[Column2]