Check Adobe Reader is installed or not (c#)

using namespage using Microsoft.Win32;

you can check  adobe reader installed or not in your system 

RegistryKey adobe = Registry.LocalMachine.OpenSubKey(“Software”).OpenSubKey(“Adobe”);
if (adobe != null)
{
RegistryKey acroRead = adobe.OpenSubKey(“Acrobat Reader”);
if (acroRead != null)
{
Process.Start(“Enter your application name here”);
}
}
else
{
System.Windows.MessageBox.Show(“Please install acrobat reader for viewing PDF”, “Information Message”, MessageBoxButton.OK, MessageBoxImage.Information);
}

How to add border on pdf using itextsharp

Tags

, , ,

Create a class that inherit by PdfPageEventHelper .
and override OnEndPage Method. please check follwoing code.

public partial class Footer : PdfPageEventHelper

{

public override void OnEndPage(PdfWriter writer, Document doc)

{

var content = writer.DirectContent;
var pageBorder = new Rectangle(doc.PageSize);

pageBorder.Left += doc.LeftMargin;
pageBorder.Right -= doc.RightMargin;
pageBorder.Top -= doc.TopMargin;
pageBorder.Bottom += doc.BottomMargin;

content.SetColorStroke(BaseColor.BLACK);
content.Rectangle(pageBorder.Left, pageBorder.Bottom, pageBorder.Width, pageBorder.Height);
content.Stroke();
}

}

after this

iTextSharp.text.Document doc = new iTextSharp.text.Document(PageSize.A4);

string path = Server.MapPath(“PDF”);
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(path + “\\hello.pdf”, FileMode.Create));

doc.Open();

writer.PageEvent = new Footer();

doc.Add(new Paragraph(“Hello World!”));

doc.Add(new Paragraph(“Hello World on a new page!”));

doc.Close();

Hello.pdf

plesae use and update me.

Rs. 163 .Coms at GoDaddy!

Operation is not valid due to the current state of the object.

System.InvalidOperationException: Operation is not valid due to the current state of the object.
at System.Web.HttpRequest.FillInFormCollection()
at System.Web.HttpRequest.get_Form()
at Rhino.Commons.LongConversationManager.LoadConversationFromRequest(Boolean& privateConversation)
at Rhino.Commons.LongConversationManager.LoadConversation()
at Rhino.Commons.HttpModules.UnitOfWorkApplication.UnitOfWorkApplication_BeginRequest(Object sender, EventArgs e)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Solution:

Add this key in web.config

Zoom image on mouse scroll and click

please check demo :
http://gopalkaroli.blogspot.in/2012/10/zoom-image-on-scroll-mouse-wheel-demo.html

using following source code:

var count=1;
function MouseScrollWheel(event) {

var rolled = 0;
if (‘wheelDelta’ in event) {
rolled = event.wheelDelta;
}
else { // Firefox
// The measurement units of the detail and wheelDelta properties are different.
rolled = -40 * event.detail;
}

var yourImg = document.getElementById(“imgTest”);
if(rolled >0)
{

if(yourImg && yourImg.style) {
yourImg.height = yourImg.height * 1.1;
yourImg.width = yourImg.width * 1.1;
}

}
else
{

if(yourImg && yourImg.style) {
yourImg.height = yourImg.height * 0.9;
yourImg.width = yourImg.width * 0.9;
}
}
}
function Init (value) {

// for mouse scrolling in Firefox
var element = document.getElementById (value.id);
if (element.addEventListener) { // all browsers except IE before version 9
// Internet Explorer, Opera, Google Chrome and Safari
element.addEventListener (“mousewheel”, MouseScrollWheel, false);
// Firefox
element.addEventListener (“DOMMouseScroll”, MouseScrollWheel, false);
}
else {
if (element.attachEvent) { // IE before version 9
element.attachEvent (“onmousewheel”, MouseScrollWheel);
}
}
}

function mouseDown(e) {
e = e || window.event;
switch (e.which) {
case 1:
count=count+0.1;
var yourImg = document.getElementById(‘imgTest’);
if(yourImg && yourImg.style) {
yourImg.height = yourImg.height * count;
yourImg.width = yourImg.width *count;
}
break;
case 2: count=count+0.1;
var yourImg = document.getElementById(‘imgTest’);
if(yourImg && yourImg.style) {
yourImg.height = yourImg.height * count;
yourImg.width = yourImg.width *count;
}
break;
case 3:
var yourImg = document.getElementById(‘imgTest’);
if(yourImg && yourImg.style) {
yourImg.height = yourImg.height *0.9;
yourImg.width = yourImg.width *0.9;
}
break;
}
}
function bigImg()
{
var x= document.getElementById(‘mainBody’);

x.style.overflow=”hidden”;

}

function normalImg()
{

var x=document.getElementById(‘mainBody’);
x.style.overflow=”auto”;
}

How do I get the max ID with Linq to Entity?

When calling Max() on an IQueryable and there are zero records I get the following exception.

The cast to value type ‘Int32’ failed because the materialized value is null. Either the result type’s generic parameter or the query must use a nullable type.

try this

C#
——–

int? maxGroupID = db.Users.Max(u => (int?)u.maxGroupID );

VB.NET

—————
Dim maxGroupID As System.Nullable(Of Integer) = db.Users.Max(Function(u) CType(u.fdGroupID, System.Nullable(Of Integer)))

How to parse json in classic asp

Tags

,

aspjson.asp download from this link http://www.aspjson.com/download.asp

[INPUT]

{
“firstName”: “John”,
“lastName” : “Smith”,
“age” : 25,
“address” :
{
“streetAddress”: “21 2nd Street”,
“city” : “New York”,
“state” : “NY”,
“postalCode” : “10021”
},
“phoneNumber”:
[
{
“type” : “home”,
“number”: “212 555-1234”
},
{
“type” : “fax”,
“number”: “646 555-4567”
}
]
}

<!–#include virtual=”/aspJSON.asp” –>

<%
Set oJSON = New aspJSON

‘Load JSON string
oJSON.loadJSON(jsonstring)

‘Get single value
Response.Write oJSON.data(“firstName”) & “<br>”

‘Loop through collection
For Each subItem In oJSON.data(“address”)
Response.Write subItem & “: ” & _
oJSON.data(“address”).item(subItem) & “<br>”
Next

‘Update/Add value
oJSON.data(“firstName”) = “James”

‘Return the object
Response.Write oJSON.JSONoutput()
%>

The method ‘Skip’ is only supported for sorted input in LINQ to Entities. The method ‘OrderBy’ must be called before the method ‘Skip’

Tags

,

 

Image

 

To fix it just add data key name in gridview

<asp:GridView
ID=”gvDepartment” runat=”server”
AllowPaging=”True”
AllowCustomPaging=”true”
AutoGenerateColumns=”False”
AllowSorting=”True”
ItemType=”–“
CssClass=”table table-hover table-condensed table-bordered table-striped grid”
GridLines=”None”
DataKeyNames=”ID”
>

Maintaining the ActiveTabIndex of the AJAX Control Toolkit TabContainer after page refresh

call TabManage function OnClientActiveTabChanged event of ajax tab container

<ajaxToolkit:TabContainer runat=”server” ID=”Tabs” Height=”500px” ScrollBars=”Vertical”
ActiveTabIndex=”0″ OnClientActiveTabChanged=” TabManage”>

function TabManage(sender, args) {
debugger;
sender.get_clientStateField().value =
sender.saveClientState();
}

How add Google Adsense ads on website

Tags

, ,

<script type=”text/javascript”>
google_ad_client = “AIzaSyDFsldP-wTV6jdR4D-MxQojl831HGXAhVI”;
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = “468x60_as”;
google_ad_type = “text_image”;
google_color_border = “FFFFFF”;
google_color_bg = “0000FF”;
google_color_link = “FFFFFF”;
google_color_text = “000000”;
google_color_url = “008000”;
</script><script type=”text/javascript” src=”http://pagead2.googlesyndication.com/pagead/show_ads.js&#8221;