Search This Blog

Friday, January 27, 2012

Cross domain useing of silverlight plugins on html page

In this article I am going to show you how to bind or consume  a silver light plugin or xap file hosted on some other domain on your html or aspx page  
using the following code you can easly load a xap file on your html or php or aspx page like a flash file 
<div>
        
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" id="silverlight-plugin"
            style="height:300px; width: 300px;">
            <param name="source" value="http://203.190.133.56/silverlight/ClientBin/SilverlightApplication1.xap"/> url of the server where xap file is hosted
            <param name="windowless" value="true"/>
<param name="onError"
             value="onSilverlightError" />
      <param name="background"
             value="Black" />
      <param name="minRuntimeVersion"
             value="4.0.50524.0" />
      <param name="autoUpgrade"
             value="True" />
<param name="enablehtmlaccess" value="true" />

      
          <param name="initParams" value="MyParameter=123,Value=123abc," />


            <p>
                You need to install Microsoft Silverlight to view this content. <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0"
                    style="text-decoration: none;">Get Silverlight!<br />
<img src="http://go.microsoft.com/fwlink/?LinkID=108181" alt="Get Microsoft Silverlight"
                        style="border-style: none;" /></a></p>
        </object>
        <iframe style="visibility: hidden; height: 0; width: 0; border-width: 0;"></iframe>
    </div>
Issue facing while consuming a xap file

if you are using the above code and you are not able to bind the component only an area is highlighted of the above mentioned height and width
in my case  style="height:300px; width: 300px;" . 
you should check the following thing
1) the url of the xap file is ok and when you paste in browser , it should start download like pdf or any other doc file.
if its not like that check for the url.
2) if the above line is ok check your firewall for that particular IP. it should not be block on your network.
3)You must have silverlight installed on your browser
if all the case are fine and still you are facing the same problem then problem is only with your hosting server. any googling is not going to help you out any more
B) if your component are loaded successfully and you are not able to use any jquey or javascript on your silver light component check the following line is added or not if not place the belo line inside your <object> tag
<param name="enablehtmlaccess" value="true" />
In my next article i will show how to code and deploy a xap file and solve the above issue of cross domain hosting
since then
Happy programming.

Monday, January 23, 2012

Pagination and sorting dynamically in SQLserver 2005/2008


Hi this article show you how to do pagination and dynamically sorting the result ascending or descending from the selection list in sql 2005/2008

Create PROCEDURE [dbo].[usp_get_all_groups] 
    -- Add the parameters for the stored procedure here
    @pStartIndex smallint,
    @pPageSize tinyint,
    @pOrderBy varchar(15)
AS
BEGIN

 SELECT *
 FROM
  (SELECT ROW_NUMBER() OVER (ORDER BY 
      CASE WHEN @pOrderBy='GroupId ASC' THEN UserGroups._id END ASC,  
      CASE WHEN @pOrderBy='GroupId DESC' THEN UserGroups._id END DESC,             
      CASE WHEN @pOrderBy='GroupCode ASC' THEN UserGroups.GroupCode END ASC,
      CASE WHEN @pOrderBy='GroupCode DESC' THEN UserGroups.GroupCode END DESC) AS Row, 
      * FROM UserGroups) AS StudentsWithRowNumbers
  WHERE Row>= @pStartIndex AND Row <= @pStartIndex + @pPageSize
  ORDER BY Row      END
Here to execute the procedure 
DECLARE @return_value int
EXEC    @return_value = [dbo].[usp_get_all_groups]
        @pStartIndex = 0,
        @pPageSize = 15,
        @pOrderBy = N'GroupCode ASC'
SELECT  'Return Value' = @return_value
Result
Row _id GroupCode   Description Type    IsActive1   1   CS2009  CS 2009 Batch   S   1
2   2   IT2009  IT 2009 Batch   S   1
3   3   ME2009  ME 2009 Batch   S   1
4   4   EC2009  EC 2009 Batch   S   1
5   5   EE2009  EE 2009 Batch   S   1
6   8   CS_F    CS Faculties    F   1
7   9   IT_F    IT Faculties    F   1
8   10  ME_F    ME Faculties    F   1
9   11  EC_F    EC Faculties    F   1
10  12  EE_F    EE Faculties    F   1
11  13  BSC_F   Basic Science Faculties F   1
12  14  Accounts    Accounts    A   1
13  15  Mgmt    Management  M   1
14  16  Lib Library B   1
15  17  TnP Training & Placement    T   1