Pages

Saturday, November 19, 2011

HOW TO SHOW IMAGES WITH ANIMATION

You will find so many scripts to do the same task but, only one issue will arise with all the scripts “does these are browser compatible”. May the answer is yes or may be no.
But, here is the solution you have to use “SpryEffects.js”. This is truly browser compatible is easy to implement.
I have a small example that is using this “JS” to animate images.

Download “SpryEffects.js” from net.

<script language="javascript" type="text/javascript">
function MM_effectGrowShrink(targetElement, duration, from, to, toggle, referHeight, growFromCenter)
{
Spry.Effect.DoGrow(targetElement, {duration: duration, from: from, to: to, toggle: toggle, referHeight: referHeight, growCenter: growFromCenter});
}
function showimage(str_path)

var obj=document.getElementById("a1"); 
str_path=str_path.replace('images/','images/large/'); 
var int_left=screen.width;
if (int_left>1024)

int_left=int_left-1024; 
int_left=int_left/2; 
int_left=int_left+251; 

else
{
int_left=50;
}

obj.style.top="50px"; 
obj.style.left=int_left +"px";
obj.style.display = 'block'; 

var viframe=document.getElementById('<%=img_show.ClientID%>').src=str_path; 
//MM_effectGrowShrink('a1', 1000, '0%', '100%', false, false, true);
MM_effectSlide('a1', 1000, '0%', '100%', false) 
}
function MM_effectAppearFade(targetElement, duration, from, to, toggle)
{
Spry.Effect.DoFade(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
}
function hidediv(str_path)
{
//MM_effectGrowShrink('a1', 1000, '100%','0%',false, false, true);
//var obj=document.getElementById("a1"); 
MM_effectSlide('a1', 1000, '100%','0%', false)
}

function MM_effectSquish(targetElement)
{
Spry.Effect.DoSquish(targetElement);
}

function MM_effectSlide(targetElement, duration, from, to, toggle)
{
Spry.Effect.DoSlide(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
}

</script>
<div ></div>
<div style="left:50px;top:50px;position:absolute;width:701px">
<img src="images/jagriti_004.jpg" onclick="showimage(this.src);" /> 
</div>
<div id="a1" style="position: absolute; background-color: Gray; display: none; width: 711px;
height: 500px;">

<img id="img_show" src="" runat="server" alt="Click to Close Enlarged View" style="margin: 0px;
padding: 0px; border: solid 5px #ffffff; height: 500px; width: 701px;" align="absmiddle" onclick="hidediv();" onmouseover="style.cursor='pointer'"/>

</div>

You can also download code which is using C#.




HOW TO SET MAX LIMT OF FILE UPLOAD IN ASP.NET

Many times I faced the same problem with all my applications, that is Max size of file to be uploaded to server.

By default, the maximum size limit of a file to be uploaded to a server using the ASP.NET FileUpload control is 4MB. You cannot upload anything that is larger than this limit. 

If you wants to upload a file more the size of 4 MB which is by default, you have to make some changes in the application's web.config:

<configuration>
<system.web>
<httpRuntime maxRequestLength="xxx" />
</system.web>
</configuration>

Below is the small description of the parameters attributes.

maxRequestLength - Attribute limits the file upload size for ASP.NET application. This limit can be used to prevent denial of service attacks (DOS) caused by users posting large files to the server. The size specified is in kilobytes. As mentioned earlier, the default is "4096" (4 MB). Max value is "1048576" (1 GB) for .NET Framework 1.0/1.1 and "2097151" (2 GB) for .NET Framework 2.0.

executionTimeout - Attribute indicates the maximum number of seconds that a request is allowed to execute before being automatically shut down by the application. The executionTimeout value should always be longer than the amount of time that the upload process can take.



HOW TO SELECT DATA FROM ANOTHER SQL SERVER

We have a target to run a JOB on server to import data from another SQL server instance.

For example take
Server 1 - Main
Server 2 - From which we have to import.

If you have admin rights on both the servers you can "Link the servers" under "Server Objects>>Linked Servers" Right click on the same and provide all the parameters of server or as an alternate you can run following command.

EXEC sp_addlinkedserver
@server = 'db1',
@srvproduct = 'SQLServer OLEDB Provider',
 @provider = 'SQLOLEDB',
 @datasrc = 'server2',
 @provstr='User Id=sa; Password=abc'

The above command parameters:-
 @server- An identification name of server.
@datasrc- Your server instance name or IP.

Your SQL will look like:-
Select * from db1.dbname.dbo.tablename

If sometimes the server will get changed, the above statement gives you the option to change the user name, password and server at any points of time without effecting the relevant SQL and SP written the basis of same.

Second Method (You can use the same if you does not have admin rights to add Linked server)

SELECT   *
FROM      OPENDATASOURCE(
         'SQLOLEDB',
         'Data Source=Server2;User ID=sa;Password=abc'
         ).dbname.dbo.tablename
        

In the above case you have to hard code all the parameters which you have to change in all the SQL and SP if something will get changed in future. So, I prefer to use Linked Server





Calories to Lose Weight

Are all calories treated the same way? The American public has been told through the media that consuming more calories than the body burns leads to weight gain. Doing the simple math this statement seems to make sense but is only partially true.



My grandmother was a nutritionist well ahead of her time – she never believed the old school of nutritional thinking that all calories are created equal. She understood that fat, protein and carbohydrate calories are different. One way to visualize that belief is to ask yourself – ‘is eating 500 calories of pure sugar the same as eating 500 calories of pure protein?’

How could different forms of calories affect you? Modern research now shows that the calories from proteins, carbohydrates, and fats have different reactions within your body in a way such that some calories really are healthier than others.  The key to this notion is your metabolism. 

Two hormones are primarily responsible for fat storage and fat energy – insulin andglucagon. These two hormones balance against each other to keep your body running properly. As you blood sugar waxes and wanes these hormones are released – for example, if your blood glucose is too low, the pancreas will secrete glucagon to raise it.

The key is to pay attention to certain foods that affect insulin release much more than other foods such as white breads, sugars, most baked goods, and most processed snack foods.  All these foods typically do is give you a short burst of energy and then a let-down. Proteins, however, will release glucagon which can decrease hunger.

How this is tied to The Diet Solution Program is that part of Isabel’s method focuses on balancing food intake that regulates these two hormones which will cause fat burning while building muscle. Food proportions in the correct ratios are key to achieving and maintaining a healthy weight.  If you tie that to the right foods for your unique metabolism type, the calories you eat when you are attempting to control appetite and lose weight should result in a healthier result.