Friday, June 26, 2009

Quotation in where condition sql-server

quotation in where condition sql-server

SELECT * FROM zzzzz WHERE zzzz = 'ZZzZ'cccc' change it
to SELECT * FROM zzzzz WHERE zzzz = 'ZZzZ''cccc'

Windows 7 Upgrade

Windows 7 is the easiest, fastest, and most engaging version of Windows yet. Better ways to find and manage files, like Jump Lists and improved taskbar previews, help you speed through everyday tasks. Faster and more reliable performance means your PC just works the way you want it to. And great features like Windows Media Center and Windows Touch make new things possible. Get to know Windows 7, and see how it can simplify just about everything you do with your PC.

Windows 7 will be available on October 22. It includes tons of little refinements—
and a few big ones—many suggested by you. The result? Everyday computing is
faster, simpler, easier.
Order Now Your Upgrade Version Save more then $100.

Windows7 Home Premium Upgrade

Windows7 Professional Upgrade

Wednesday, June 24, 2009

Twitter asp.net 2.0, C# sample

I created following application to post in Twitter by using twitter apis..in asp.net 2.0, C#
 
 
<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %>

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

html xmlns="http://www.w3.org/1999/xhtml" >

<

head runat="server">

<title>Untitled Page</title>

</

head>

<

body>

<form id="form1" runat="server">

<div>

<table style="width: 50%" align="center">

<tr>

<td>

</td>

<td>

</td>

<td>

</td>

</tr>

<tr>

<td align="right">

<asp:Label ID="Label2" runat="server" Text="User Id:"></asp:Label></td>

<td>

<asp:TextBox ID="txtusrid" runat="server" Width="144px"></asp:TextBox>

</td>

<td>

</td>

</tr>

<tr>

<td align="right">

<asp:Label ID="Label3" runat="server" Text="Password:"></asp:Label></td>

<td>

<asp:TextBox ID="txtpass" runat="server" TextMode="Password"></asp:TextBox></td>

<td>

</td>

</tr>

<tr>

<td align="right" style="height: 40px">

<asp:Label ID="Label1" runat="server" Text="Messages:"></asp:Label></td>

<td style="height: 40px">

<asp:TextBox ID="txtmessage" runat="server" TextMode="MultiLine" Width="259px" Height="99px"></asp:TextBox>

</td>

<td style="height: 40px">

</td>

</tr>

<tr>

<td style="height: 21px">

</td>

<td style="height: 21px">

<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" />

<asp:Label ID="Label4" runat="server" Width="126px"></asp:Label></td>

<td style="height: 21px">

</td>

</tr>

</table>

</div>

</form>

</

body>
</
html>
 
Code behind

using

System;

using

System.Net;

using

System.Web;

using

System.IO;

public

partial class Default5 : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

public void SubmitUserMsg(string username, string passwd, string txttweet)

{

string user = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + passwd));

byte[] bytes = System.Text.Encoding.ASCII.GetBytes("status=" + txttweet);

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://twitter.com/statuses/update.xml");

request.Method =

"POST";

request.ServicePoint.Expect100Continue = false;

request.Headers.Add(

"Authorization", "Basic " + user);

request.ContentType =

"application/x-www-form-urlencoded";

request.ContentLength = bytes.Length;

Stream reqStream = request.GetRequestStream();

reqStream.Write(bytes, 0, bytes.Length);

reqStream.Close();

Label4.Text =

"Message Posted";

}

protected void Button1_Click(object sender, EventArgs e)

{

SubmitUserMsg(txtusrid.Text, txtpass.Text, txtmessage.Text);

}

}

Tuesday, June 23, 2009

Error: Sys.WebForms.PageRequestManagerParserErrorException:

Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

change this <asp:ScriptManager ID="ScriptManager1" runat="server" />
to this <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="false" />
this may fix your problem

HTML Editor ajax toolkit 3.5 vs 2008 Sample

Working sample for HTML Editor ajax toolkit 3.5 VS 2008 Sample ..Rich textbox sample...
 
 
 
<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" EnableEventValidation="false" ValidateRequest="false" Trace="false"%>

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%

@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<%

@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="HTMLEditor" %>

<

html xmlns="http://www.w3.org/1999/xhtml">

<

head runat="server">

<title>Untitled Page</title>

</

head>

<

body>

<form id="form1" runat="server">

<

div>

<asp:ScriptManager ID="ScriptManager1" runat="server" />

<script type="text/javascript">

</script>

<asp:UpdatePanel ID="updatePanel1" runat="server">

<ContentTemplate>

<HTMLEditor:Editor runat="server" Id="editor" Height="300px" AutoFocus="true" Width="100%" />

<br />

<asp:Button runat="server" Text="Submit content" ID="submit"

onclick="submit_Click" />

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

</ContentTemplate>

</asp:UpdatePanel>

</div>

</form>

</

body>

</

html>

Monday, June 22, 2009

Could not load type 'System.Web.UI.ScriptReferenceBase' from assembly 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. error

getting error
Could not load type 'System.Web.UI.ScriptReferenceBase' from assembly 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
 
 
change:
<ajaxToolkit:ToolkitScriptManager ID="ScriptManager1" runat="server" />
 
to: <asp:ScriptManager ID="ScriptManager1" runat="server" />

 

Encrypting the Web.Config File -- Visual Studio Magazine

Encrypting the Web.Config File -- Visual Studio Magazine

Sunday, June 21, 2009

What is Google Wave?

Google Wave is a new tool for communication and collaboration on the web, coming later this year.
 
 
api: code.google.com/apis/wave/
 
 

Friday, June 19, 2009

How to generate serial Number in DataList? asp.net

How to generate serial Number in DataList?


<asp:TemplateField HeaderText="SLr.No">
           <ItemTemplate>
          <asp:Label ID="lbSnNo" runat="Server" Text='<%# Container.ItemIndex + 1 %>' />
           </ItemTemplate>
</asp:TemplateField>

 

How to Define style in code behind C#?

Sample:
dynTable =
"<table align=\"center\" width=\"85%\" cellspacing=\"0\" cellpadding=\"3\" border=\"1\" style=\"width:100%;border-collapse:collapse; border-style:solid; border-width:1\">";

Active desktop recovery problem

Getting following error when try to do active desktop revovery.
 
I fixed my pc I went to desktop ->right click on properties ->desktop ->select windows XP -OK
and its fixed.
 
 
 

Thursday, June 18, 2009

Newsletter sample template using access database , C# and smtp

Newsletter format using access database , C# and smtp

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="nl1.aspx.cs" Inherits="nl1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%; " id="maintabl" runat="server">
<tr>
<td colspan="1" align="center" >



&nbsp; &nbsp; &nbsp;
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Send" /></td>
</tr>
<tr>
<td valign="top">
<asp:Label ID="Label1" runat="server" Text="Label" BackColor="Transparent" Width="100%"></asp:Label><br />

<br />
<br />
</td>
</tr>
<tr>
<td colspan="1" style="height: 20px" align="center" >
<asp:Label ID="labmsg" runat="server"></asp:Label></td>
</tr>
</table>
&nbsp;
&nbsp;&nbsp;
<br />
<br />
<br />
<br />
</div>
</form>
</body>
</html>

Code Behind......

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.Web.Mail;

public partial class nl1 : System.Web.UI.Page
{
string dynTable = "";
protected void Page_Load(object sender, EventArgs e)
{
string connectionString = "provider=Microsoft.Jet.OLEDB.4.0;data source=c:\\xxxx\\database\\MailDB.mdb";
OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);
OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand();
string ProdTy = "M2";
string Strsql = "SELECT top 5 * from DetailURLMisc ";
myOleDbCommand.CommandText = Strsql;
myOleDbConnection.Open();
OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader();
myOleDbDataReader.Read();

dynTable = "<table align=\"center\" width=\"95%\" cellspacing=\"0\" cellpadding=\"3\" border=\"1\">";
dynTable += "<tr><td height=\"50px\" style=\"background-color:Blue\" colspan=\"3\">"
+"<a href=\"default.aspx\" style=\"text-decoration: none\"><font class=\"X-small\""
+"color=\"gold\" size=\"6\"><font color=\"red\" face=\"Monotype Corsiva\">Header</font></font></a>"
+ "</td></tr>";
dynTable += "<tr><td height=\"25px\" style=\"background-color:Silver\" colspan=\"3\">Header2</td></tr>";
dynTable += "<tr>";
dynTable += "<td width=\"20%\">&nbsp;1</td>";
dynTable += "<td width=\"50%\" valign=\"top\">President Barack Obama's plan to transform the Federal Reserve into a super-regulator ran into skepticism Thursday from lawmakers who worry that the central bank is not the best suited to keep an eye on firms deemed so big and influential that their demise could hurt the economy.</td>";
dynTable += "<td width=\"30%\">";
while (myOleDbDataReader.Read())
{

//dynTable += "<td>"+(myOleDbDataReader["TextUrl"].ToString())+"</td>";

dynTable += "<a href=" + myOleDbDataReader["NameUrl"].ToString() + "><img border=0 src=" + (myOleDbDataReader["ImageUrl"].ToString()) + "xxx></img></a>"
+ "<a href=" + myOleDbDataReader["NameUrl"].ToString() + ">" + (myOleDbDataReader["TextUrl"].ToString()) + "</a><br/>";

}
dynTable += "</td></tr>";
dynTable += "<tr><td height=\"25px\" style=\"background-color:Silver\" colspan=\"3\">&nbsp;Footer</td></tr>";
dynTable += "</table>";
Label1.Text = dynTable.ToString();

}

void sndmail()
{
MailMessage oMessage = new MailMessage();
oMessage.To = "xxxxxx@gmail.com";
oMessage.From = "vvvvv@xxxxxx.net";
System.Text.StringBuilder sb = new System.Text.StringBuilder();
oMessage.Subject = "Great Find";
oMessage.Body = dynTable;
oMessage.BodyFormat = MailFormat.Html;
//oMessage.Attachments = txtBody.Text;
//Response.Write("http://www.visli.com/" + System.IO.Path.GetFileName(Request.Url.ToString()));
oMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2;
oMessage.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"] = "mail.xxxxx.net";
oMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "kkkkk@xxxxxx.net";
//oMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "xxxxx";
oMessage.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
System.Web.Mail.SmtpMail.SmtpServer = "mail.xxxxxx.net";//
try
{
oMessage = oMessage;
System.Web.Mail.SmtpMail.Send(oMessage);
labmsg.Text = "Message Send";
}
catch (Exception Ex)
{
labmsg.Text = ("Unable to send mail! " + Ex.Message);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
//Label2.Text = maintabl;
sndmail();
}
}

Monday, June 15, 2009

Gridview Template, Data-Binding in a Template asp.net

Gridview Template, Data-Binding in a Template asp.net



<Columns>
<asp:BoundField DataField="EmployeeID" HeaderText="Employee ID" ReadOnly="true"/>
<asp:BoundField DataField="FirstName" HeaderText="First Name"/>
<asp:BoundField DataField="LastName" HeaderText="Last Name"/>
<asp:TemplateField HeaderText="Birth Date">
<ItemTemplate>
<asp:Label ID="BirthDateLabel" Runat="Server"
Text='<%# Eval("BirthDate", "{0:d}") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:Calendar ID="EditBirthDateCalendar" Runat="Server"
VisibleDate='<%# Eval("BirthDate") %>'
SelectedDate='<%# Bind("BirthDate") %>' />
</EditItemTemplate>
</asp:TemplateField>
<asp:HyperLinkField Text="Show Detail"
DataNavigateUrlFormatString="~/ShowEmployeeDetail.aspx?EmployeeID={0}"
DataNavigateUrlFields="EmployeeID" />
</Columns>


Source: http://msdn.microsoft.com/en-us/library/ms228046.aspx

Build your own Whois Lookup with ASP.NET and jQuery

Build your own Whois Lookup with ASP.NET and jQuery

.NET - Programmatically manipulating web.config in ASP.NET 2.0 and ASP.NET 3.5

.NET - Programmatically manipulating web.config in ASP.NET 2.0 and ASP.NET 3.5

Friday, June 12, 2009

RSS Feed, Affiliate Link Capture on Same Page - C#

The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see ASP.NET Web Page Code Model.
 
<%@ Page Language="C#" AutoEventWireup="True" %>
<%@ Import Namespace="System.Data" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >
   <script language = "C#" runat="server">

      ICollection CreateDataSource()
      {
         DataTable dt = new DataTable();
         DataRow dr;

         dt.Columns.Add(new DataColumn("StringValue", typeof(string)));

         for (int i = 0; i < 10; i++)
         {
            dr = dt.NewRow();
            dr[0] = "Item " + i.ToString();
            dt.Rows.Add(dr);
         }

         DataView dv = new DataView(dt);
         return dv;
      }

      void Page_Load(Object sender, EventArgs e)
      {
         if (!IsPostBack)
         {
            DataList1.DataSource = CreateDataSource();
            DataList1.DataBind();
         }
      }

      void Button_Click(Object sender, EventArgs e)
      {
         if (DataList1.Items.Count > 0)
         {
            Label1.Text = "The Items collection contains: <br />";

            foreach(DataListItem item in DataList1.Items)
            {

               Label1.Text += ((DataBoundLiteralControl)item.Controls[0]).Text +
                              "<br />";
            }
         }
      }

   </script>

<head runat="server">
    <title>DataList Items Example</title>
</head>
<body>

   <form id="form1" runat="server">

      <h3>DataList Items Example</h3>

      <asp:DataList id="DataList1" runat="server"
           BorderColor="black"
           CellPadding="3"
           Font-Names="Verdana"
           Font-Size="8pt">

         <HeaderStyle BackColor="#aaaadd">
         </HeaderStyle>

         <AlternatingItemStyle BackColor="Gainsboro">
         </AlternatingItemStyle>

         <HeaderTemplate>

            Items

         </HeaderTemplate>

         <ItemTemplate>

            <%# DataBinder.Eval(Container.DataItem, "StringValue") %>

         </ItemTemplate>

      </asp:DataList>

        <br /><br />

      <asp:Button id="Button1"
           Text="Display Contents of Items Collection"
           OnClick="Button_Click"
           runat="server"/>

      <br /><br />

      <asp:Label id="Label1"
           runat="server"/>

   </form>

</body>
</html>

Sourcse: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datalist.items.aspx

Building Cascading DropDownList in ASP.Net Using jQuery and JSON

Building Cascading DropDownList in ASP.Net Using jQuery and JSON

Wednesday, June 10, 2009

Redirect URL using 301 redirection for affiliate Marketing

Redirect URL using 301 redirection for affiliate Marketing

Method 1.
 protected void Page_Load(object sender, EventArgs e)
    {
 Response.Status = "301 Moved Permanently";
 Response.AddHeader("Location", NEW_URL);

    }

Method 2.
protected void Application_BeginRequest(Object sender, EventArgs e)
  {
   string sOldPath = HttpContext.Current.Request.Path.ToLower();
   

   string sPage = "http://www.aspcode.net/articles/" + sOldPath;
   Response.Clear();
   Response.Status = "301 Moved Permanently";
   Response.AddHeader("Location",sPage);
   Response.End();
  }

Method 3.

protected override void OnInit(EventArgs e)
{
    int i = Request.Url.ToString().IndexOf("www.");
    if (i < 8 && i != -1)
    {
        Response.Clear();
        Response.Status = "301 Moved Permanently";
        Response.AddHeader("Location", Request.Url.ToString().Remove(i, 4));
        Response.End();
    }
    base.OnInit (e);
}

 

 

.NET - Read Data From an Excel File (.xls) in ASP.NET

.NET - Read Data From an Excel File (.xls) in ASP.NET

Tuesday, June 9, 2009

Using RoleService for Role Based Forms Authentication in ASP.NET AJAX

Using RoleService for Role Based Forms Authentication in ASP.NET AJAX

Google Checkout Custom Control

Google Checkout Custom Control
Google recently introduce Google Checkout. "Google Checkout is a checkout process that you integrate with your website, enabling your customers to buy from you quickly and securely, using a single username and password. Once they do, you can use Google Checkout to charge their credit cards, process their orders, and receive payment in your bank account."

They currently have no ASP.NET examples posted on their site so I have created an ASP.NET 2.0 Custom Web Control that will allow you to easily integrated with their service by simply dropping a control on the page a specifying a few parameters. So here it is...


http://www.c-sharpcorner.com/UploadFile/jlf0002/googlecheckoutcustomcontrol08072006134735PM/googlecheckoutcustomcontrol.aspx

Tuesday, June 2, 2009

SQL-Server Order by Random

select top 10 * from proddta.f4072 order by newid()