Friday 2 November 2012

How to add bookmark on pdf file using itextsharp


 Document document = new Document(PageSize.A4, 50, 50, 25, 25);

            // Create a new PdfWriter object, specifying the output stream
         
            PdfWriter.GetInstance(document, new FileStream(Server.MapPath(“MyFirstPDF.pdf”), FileMode.Create));

            Chapter chapter1 = new Chapter(new Paragraph(“This is Chapter 1″), 1);
            Section section1 = chapter1.AddSection(20f, “Section 1.1″, 2);
            Section section2 = chapter1.AddSection(20f, “Section 1.2″, 2);
            Section subsection1 = section2.AddSection(20f, “Subsection 1.2.1″, 3);
            Section subsection2 = section2.AddSection(20f, “Subsection 1.2.2″, 3);
            Section subsubsection = subsection2.AddSection(20f, “Sub Subsection 1.2.2.1″, 4);
            Chapter chapter2 = new Chapter(new Paragraph(“This is Chapter 2″), 1);
            Section section3 = chapter2.AddSection(“Section 2.1″, 2);
            Section subsection3 = section3.AddSection(“Subsection 2.1.1″, 3);
            Section section4 = chapter2.AddSection(“Section 2.2″, 2);
            chapter1.BookmarkTitle = “Changed Title”;
            chapter1.BookmarkOpen = true;
            chapter2.BookmarkOpen = true;
            document.Add(chapter1);
            document.Add(chapter2);
            // Add the Paragraph object to the doc

How to Share a Link on Twitter


Please click on image and check

please use this code

<img id="ctl00_ctl00_ShareLink1_imgTwitter" border="0" onclick="ShareName('twitter')" src="images/icons/Twitter.png" alt="Twitter" style="border-width:0px;">
:
<script type="text/javascript"> var path = ""; var text = ""; function ShareName(title) { if (title == "twitter") { path = "http://twitter.com/share?url="; text = "&text="; ShareLink(path, text); } } function ShareLink(path, text) { var title = document.title; title = encodeString(title); var url = document.location; url = encodeString(url); var link = url + text + title; link = path + link; window.open(link); return false; } function encodeString(text) { var output = escape(text); output = output.replace("+", "%2B"); output = output.replace("/", "%2F"); return output; } </script>

Monday 29 October 2012

Online Credit Card Transaction in ASP.NET Using PayPal Pro / dodirect

  string strUsername = "api user name";
            string strPassword = "pasword";
            string strSignature = "signature";
            string strCredentials = "USER=" + strUsername + "&PWD=" + strPassword + "&SIGNATURE=" + strSignature;

            string strNVPSandboxServer = "https://api-3t.sandbox.paypal.com/nvp";
            string strAPIVersion = "50.0";
       
            string strNVP = strCredentials + "&METHOD=DoDirectPayment" +
            "&CREDITCARDTYPE=" + "credit card type"+
            "&ACCT=" + "credit card number" +
            "&EXPDATE=" + "expire date" +
            "&CVV2=" + "cvv number"+
            "&AMT=" + "100" +
            "&FIRSTNAME=" + "Gopal" +
            "&LASTNAME=" + "Singh"+
            "&IPADDRESS= ip address" +
            "&STREET=" + "street" +
            "&CITY=" + "city"+
            "&STATE=" +"state"+
            "&COUNTRY=" + "contry" +
            "&ZIP=" +"1234" + "" +
            "&CURRENCYCODE=GBP" +
            "&PAYMENTACTION=Sale" +
            "&VERSION=" + strAPIVersion;


            try
            {
                //Create web request and web response objects, make sure you using the correct server (sandbox/live)
                HttpWebRequest wrWebRequest = (HttpWebRequest)WebRequest.Create(strNVPSandboxServer);
                wrWebRequest.Method = "POST";
                StreamWriter requestWriter = new StreamWriter(wrWebRequest.GetRequestStream());
                requestWriter.Write(strNVP);
                requestWriter.Close();

                // Get the response.
                HttpWebResponse hwrWebResponse = (HttpWebResponse)wrWebRequest.GetResponse();
                StreamReader responseReader = new StreamReader(wrWebRequest.GetResponse().GetResponseStream());

                //and read the response
                string responseData = responseReader.ReadToEnd();
                responseReader.Close();

                string result = Server.UrlDecode(responseData);

                string[] arrResult = result.Split('&');
                Hashtable htResponse = new Hashtable();
                string[] responseItemArray;
                foreach (string responseItem in arrResult)
                {
                    responseItemArray = responseItem.Split('=');
                    htResponse.Add(responseItemArray[0], responseItemArray[1]);
                }

                string strAck = htResponse["ACK"].ToString();
                Response.Write(strAck);

                if (strAck == "Success" || strAck == "SuccessWithWarning")
                {
                    string strAmt = htResponse["AMT"].ToString();
                    string strCcy = htResponse["CURRENCYCODE"].ToString();
                    string strTransactionID = htResponse["TRANSACTIONID"].ToString();
                    string strSuccess = "Thank you, your order for: $" + strAmt + " " + strCcy + " has been processed.";


                }
                else
                {
                    string strErr = "Error: " + htResponse["L_LONGMESSAGE0"].ToString();
                    string strErrcode = "Error code: " + htResponse["L_ERRORCODE0"].ToString();
           

                }
            }
            catch (Exception ex)
            {
                // do something to catch the error, like write to a log file.
                // Response.Write("error processing");
                //  Response.End();
             
            }

Friday 12 October 2012

convert text file into csv file in c#


  try
            {

             
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Title = "Open file as...";
                dialog.Filter = "txt files (*.txt)|*.txt";
                dialog.RestoreDirectory = true;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    string csvFileName = dialog.FileName;
                    //get the user to specify the                  
                    TextReader reader = new StreamReader(csvFileName);
                    string a = reader.ReadToEnd();

                    char[] array = a.ToCharArray();

                    reader.Close();
                    MessageBox.Show("File Converted! Please save");

                    SaveFileDialog dialogSave = new SaveFileDialog();
                    dialogSave.Title = "Save file as...";
                    dialogSave.Filter = "CSV files (*.csv)|*.csv";
                    dialogSave.RestoreDirectory = true;

                    if (dialogSave.ShowDialog() == DialogResult.OK)
                    {
                        string saveFile = dialogSave.FileName;
                        //get the user to specify the                



                        FileStream aFile = new FileStream(saveFile, FileMode.OpenOrCreate);

                    StreamWriter sw = new StreamWriter(aFile);

                    for (int i = 0; i < array.Length; i++)
                    {

                        if (array[i] == '\n' && array[i] == '\r')

                            sw.WriteLine();

                        else

                            sw.Write(a[i] + ",");

                    }

                    sw.Close();
                    }
                 
                }



            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error creating the download report:" + ex.Message);

            }

Thursday 16 August 2012

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();
                }

Tuesday 3 July 2012

how to call indeed api in classic asp


<%@LANGUAGE="VBSCRIPT"%>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en" lang="en">
<head>

<title>Indeed Api Call</title>
<meta name="title" content="testing" />
</head>
<body>
<div class="vevent">
 
   <%
   dim use
 use=Request.ServerVariables("HTTP_USER_AGENT")
  if request("fj") <>"" then
  as_and=request("as_and")
 as_phr=request("as_phr")
 as_any=request("as_any")
  as_not=request("as_not")
 as_ttl=request("as_ttl")
 as_cmp=request("as_cmp")
 jt=request("jt")
   st=request("st")
  salary=request("salary")
   radius=request("radius")
     l=request("l")
  fromage=request("fromage")
  limit=request("limit")
   sort=request("sort")

Dim req
Set req = Server.CreateObject("MSXML2.ServerXMLHTTP")

req.open "GET", "http://api.indeed.com/ads/apisearch?publisher=9116108067858202&q="&as_and&"&as_phr="&as_any&"&as_not="&as_not&"&l="&l&"&as_ttl="&as_ttl&"&sort="&sort&"&radius=&st="&st&"&jt="&jt&"&start=&limit="&limit&"&fromage="&fromage&"&filter=&latlong=1&co=us&chnl=&userip=1.2.3.4&useragent="&use&"&v=2", False
req.send()

Set objXML = Server.CreateObject("Microsoft.XMLDOM")
 Set objLst = Server.CreateObject("Microsoft.XMLDOM")
 Set objHdl = Server.CreateObject("Microsoft.XMLDOM")
 objXML.async = False
 objXML.Load (req.responseXml)
 Set xml_tree2 = objXML.getElementsByTagName("result")
 dim a:a=req.responseXml.xml
Set xml_tree1 = Nothing
%>
<div style=" min-height:500px; width:500px;">
<%
for i = 0 to (xml_tree2.length - 1)
    set xml_tree3 = xml_tree2.item(i)
    test=    isobject(xml_tree3.childnodes(9))
    IF isobject(xml_tree3.childnodes(9)) AND  isobject(xml_tree3.childnodes(0)) AND  isobject(xml_tree3.childnodes(8)) AND  isobject(xml_tree3.childnodes(16)) AND isobject(xml_tree3.childnodes(17)) THEN
    response.write( "<a href='"&xml_tree3.childnodes(9).text&"' >"&xml_tree3.childnodes(0).text&"</a><br>")
    response.write(xml_tree3.childnodes(8).text&"<bR>")
  response.write(xml_tree3.childnodes(16).text&"<bR>")  
    response.write("<font style='color:#20f120;'>"&xml_tree3.childnodes(17).text&"</font><bR>")
   
   end if
   next


    %>

  </div>
  <% end if %>
</div>
<%   if request("fj") ="" then %>>
<form >

<table cellspacing="0" cellpadding="3" border="0" align="center">
<tbody><tr>
<td><h1>Advanced Job Search</h1></td>
</tr>
<tr>
<td>

<table cellspacing="0" cellpadding="3" border="0">
<tbody><tr><td colspan="2" class="header">Find Jobs</td></tr>
<tr>
<td width="150" nowrap=""><label for="as_and">With <b>all</b> of these words</label></td>
<td><input type="text" value="" maxlength="512" size="35" name="as_and" id="as_and"></td>
</tr>
<tr>
<td nowrap=""><label for="as_phr">With the <b>exact phrase</b></label></td>
<td><input type="text" value="" maxlength="512" size="35" name="as_phr" id="as_phr"></td>
</tr>
<tr>
<td nowrap=""><label for="as_any">With <b>at least one</b> of these words</label></td>
<td><input type="text" value="" maxlength="512" size="35" name="as_any" id="as_any"></td>
</tr>
<tr>
<td nowrap=""><label for="as_not">With <b>none</b> of these words</label></td>
<td><input type="text" value="" maxlength="512" size="35" name="as_not" id="as_not"></td>
</tr>
<tr>
<td nowrap=""><label for="as_ttl">With these words in the <b>title</b></label></td>
<td><input type="text" value="" maxlength="512" size="35" name="as_ttl" id="as_ttl"></td>
</tr>
<tr>
<td nowrap=""><label for="as_cmp">From this <b>company</b></label></td>
<td><input type="text" value="" maxlength="512" size="35" name="as_cmp" id="as_cmp"></td>
</tr>


<tr>
<td nowrap=""><label for="jt">Show jobs of type</label></td>
<td>
<select name="jt" id="jt">
<option value="all">All job types</option>
                         
                            <option value="fulltime">Full-time</option>
                         
                            <option value="parttime">Part-time</option>
                         
                            <option value="contract">Contract</option>
                         
                            <option value="internship">Internship</option>
                         
                            <option value="temporary">Temporary</option>
                         
</select>
</td>
</tr>

<tr>
<td nowrap=""><label for="st">Show jobs from</label></td>
<td>
<select name="st" id="st">
<option value="">All web sites</option>
<option value="jobsite">Job boards only</option>
<option value="employer">Employer web sites only</option>
</select>
</td>
</tr>
<tr>
<td nowrap="">&nbsp;</td>
<td>
<input type="checkbox" value="directhire" name="sr" id="norecruiters">&nbsp;<label for="norecruiters">Exclude staffing agencies</label>
</td>
</tr>





<tr id="sal_item">
<td style="vertical-align:top" class="col_a"><label for="salary">Salary estimate</label></td>
<td><table cellspacing="0" cellpadding="0"><tbody><tr><td><input type="text" size="17" value="" name="salary" id="salary"> per year</td></tr><tr><td><span style="font-size:smaller;color:#666" class="example">$50,000 or $40K-$90K</span></td></tr></tbody></table></td>
</tr>


<tr><td colspan="2" class="header">Where and When</td></tr>
<tr>
<td nowrap="" colspan="1" style="padding:5px 3px;">
                     
<label for="radius"><b>Location</b></label>&nbsp;
<select name="radius" id="radius">


<option value="0">only in</option>






<option value="5">within 5 miles of</option>






<option value="10">within 10 miles of</option>






<option value="15">within 15 miles of</option>






<option value="25" selected="">within 25 miles of</option>






<option value="50">within 50 miles of</option>






<option value="100">within 100 miles of</option>



</select>&nbsp;
                    </td>
                    <td>
<input type="text" value="" maxlength="250" size="28" name="l" id="where" autocomplete="off">&nbsp;(city, state, or zip)

</td>
</tr>
                <tr><td></td><td class=""><div style="position:relative;z-index:2"><div style="display:none;" class="acd" id="acdiv"></div></div></td></tr>
<tr>
<td nowrap="" colspan="2" style="padding:5px 3px;">
<b>Age</b> - <label for="fromage">Jobs published</label>&nbsp;
<select name="fromage" id="fromage">
<option value="any">anytime</option>
                         
                                <option value="15">within 15 days</option>
                         
                                <option value="7">within 7 days</option>
                         
                                <option value="3">within 3 days</option>
                         
                            <option value="1">since yesterday</option>
   <option value="last">since my last visit</option>

</select>
</td>  
</tr>
<tr>
<td nowrap="" colspan="2" style="padding:5px 3px;">
<label for="limit"><b>Display</b></label>&nbsp;
<select name="limit" id="limit">
                         
                            <option value="10" selected="">10</option>
                         
                            <option value="20">20</option>
                         
                            <option value="30">30</option>
                         
                            <option value="50">50</option>
                         
</select>
&nbsp;results per page, <label for="sort">sorted by</label>&nbsp;
<select name="sort" id="sort">
<option value="" selected="">relevance</option>
<option value="date">date</option>
</select>
&nbsp;&nbsp;&nbsp;<input type="submit" value="Find Jobs"  name="fj" id="fj">
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
    </form>
    <% end if %>
</body>

</html>

Thursday 17 May 2012

Android-How to navigate from one screen to another screen


  Button btn= (Button)findViewById(R.id.button1);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {                  
            Intent inte=new Intent(TestActivity.this,second.class);
            startActivity(inte);

            }
        });

Wednesday 16 May 2012

Get QueryStrings using Javascript

function getQuerystring(key, default_) { if (default_==null) default_=""; key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regex = new RegExp("[\\?&]"+key+"=([^&#]*)"); var qs = regex.exec(window.location.href); if(qs == null) return default_; else return qs[1]; }
The getQuerystring function is simple to use. Let's say you have the following URL:

http://www.test.com?a=gopal
and you want to get the "a" querystring's value:
var author_value = getQuerystring('a');
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)
Cause:
Microsoft recently (12-29-2011) released an update to address several serious security vulnerabilities in the .NET Framework. MS11-100 was introduced just recently that handles potential DoS attacks.  
Unfortunately the fix has also broken page POSTs with very large amounts of posted data (form fields). MS11-100 places a limit of 500 on postback items. The new default max introduced by the recent security update is 1000.  
Adding the setting key to the web-config file overcomes this limitation, as in this example increases it to 2000.  

Saturday 7 January 2012


Binding listbox and dropdown list using javascript - ASP.NET


we call a web service that return list<Employee> .

 $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "../WebServices/servicename.asmx/methodname",
                data: JSON.stringify({}),
                dataType: "json",
                success: BindEmployeeSucceeded,
                error: BindEmployeeFailed
            });

function BindEmployeeSucceeded(result) {
            var columns = result.d;
            $('#<%=lbEmployee.ClientID %>').empty();
            $('#<%=
lbEmployee
.ClientID %>').append('<option value="' + "0" + '">' + "Select" + '</option>');
            for (var i = 0; i < columns.length; i++) {
                $('#<%=
lbEmployee
.ClientID %>').append('<option value=' + columns[i].Id + '>' + columns[i].OrganisationName + '</option>');
            }
        }

        function BindEmployeeFailed() {

        }

note: OrganisationName and Id are properties of Employee 

normalization


(1) In relational database design, the process of organizing data to minimize redundancy. Normalization usually involves dividing a database into two or more tables and defining relationships between the tables. The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships.

There are three main normal forms, each with increasing levels of normalization:
  • First Normal Form (1NF): Each field in a table contains different information. For example, in an employee list, each table would contain only one birthdate field.
  • Second Normal Form (2NF): Each field in a table that is not a determiner of the contents of another field must itself be a function of the other fields in the table.
  • Third Normal Form (3NF): No duplicate information is permitted. So, for example, if two tables both require a birthdate field, the birthdate information would be separated into a separate table, and the two other tables would then access the birthdate information via an indexfield in the birthdate table. Any change to a birthdate would automatically be reflect in all tables that link to the birthdate table.
  • There are additional normalization levels, such as Boyce Codd Normal Form (BCNF), fourth normal form (4NF) and fifth normal form (5NF). While normalization makes databases more efficient to maintain, they can also make them more complex because data is separated into so many different tables.
    (2) In data processing, a process applied to all data in a set that produces a specific statistical property. For example, each expenditure for a month can be divided by the total of all expenditures to produce a percentage.
    (3) In programming, changing the format of a floating-point number so the left-most digit in the mantissa is not a zero.

    normalization

    How to read data from xml file 




    using MSXML6.0.DLL


     Using System.Xml.DLL

    DOMDocumentClass document = new DOMDocumentClass();

    document .load("d:\\gopal\\test.xml");

    IXMLDOMElement p =   document .documentElement;

    for (int i = 0; i <  p.childNodes.length ; i++)

    {


    MessageBox.Show(p.childNodes[i].childNodes[0].text + " " + p.childNodes[i].childNodes[5



    ].text); 

    }