Saturday, November 29, 2008

WebPage / Screen Scraping Html to Sql-Server, code sample VB.NET asp.net 2.0

This is the sample in vb asp.net 2.0, sql-server express 2005 if you want to scrap page from url want to insert in sql-server table.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="htmltosql.aspx.vb" Inherits="htmltosql" validateRequest="false" %>

<!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>
<asp:TextBox runat="server" id="amzTop" TextMode="MultiLine" Columns="360" Rows="15" /><br />
<asp:Button ID="Button1" runat="server" Text="Button" /><br />
<br />

</div>
</form>
</body>
</html>


Code Behind

Imports System.Data.SqlClient
Imports System
Imports System.IO
Imports System.Xml
Imports System.Net


Partial Class htmltosql
Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ,Button1.Click
insertdata()

End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim req As HttpWebRequest = WebRequest.Create("http://www.yahoo.com/")
Try
'Get the data as an HttpWebResponse object
Dim resp As HttpWebResponse = req.GetResponse()
'Convert the data into a string (assumes that you are requesting text)
Dim sr As New StreamReader(resp.GetResponseStream())
Dim results As String = sr.ReadToEnd()
sr.Close()
amzTop.Text = results
Catch wex As WebException
Response.Write("<font color=red>SOMETHING WENT AWRY!<br />Status: " & wex.Status & "Message: " & wex.Message & "</font>")
End Try
End Sub

Public Sub insertdata()

'Response.Write(amzTop.Text)
'Response.End()


Dim con As New SqlConnection("Data Source=testserver\SQLEXPRESS;Initial Catalog=test_DV;Integrated Security=True")
Dim cmd As New SqlCommand("insbulkhtml", con)

cmd.CommandType = Data.CommandType.StoredProcedure

cmd.Parameters.AddWithValue("@htmlstr", LTrim(amzTop.Text))
Using con
con.Open()
cmd.ExecuteNonQuery()
End Using
End Sub


End Class

stored proc

Create proc [dbo].[insbulkhtml]
@htmlstr nvarchar(max) as
delete from tem_tab1
INSERT into tem_tab1
select @htmlstr


Table

CREATE TABLE [dbo].[tem_tab1](
[Prodcode] [nvarchar](max) NULL
) ON [PRIMARY]

Tuesday, November 25, 2008

Create a webservice directly from Sql Server 2005 /2008 using an HTTP

Create a web service directly from Sql Server 2005 using an HTTP Endpoint


use adventureworksgo
CREATE ENDPOINT GetEmployees STATE = STARTEDAS HTTP( PATH = '/Employee', AUTHENTICATION = (INTEGRATED), PORTS = (CLEAR), SITE = 'localhost')FOR SOAP( WEBMETHOD 'EmployeeList' (NAME='AdventureWorks.dbo.GetEmployees'), BATCHES = DISABLED, WSDL = DEFAULT, DATABASE = 'AdventureWorks', NAMESPACE = 'http://AdventureWorks/Employee')
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Create a new instance of the web service
Dim employeesProxy As adventureWorksService.GetEmployees = New adventureWorksService.GetEmployees

' You have to pass in credentials to authenticate yourself to use the service. We are just going to use
' the same credentials we have logged into our computer as.
employeesProxy.Credentials = System.Net.CredentialCache.DefaultCredentials

' The result of a SELECT statement via an endpoint can be converted to a DataSet
Dim ds As System.Data.DataSet = DirectCast(employeesProxy.EmployeeList, DataSet)

ListBox1.DataSource = ds.Tables(0)
ListBox1.DisplayMember = "FullName"
ListBox1.ValueMember = "EmployeeId"

End Sub
End Class

Saturday, November 22, 2008

Retain Scroll / Page Position After postback c# asp.net

  Programmatically

Page.MaintainScrollPositionOnPostBack = true;
 page declaration

<%@ Page MaintainScrollPositionOnPostback="true" %>
Or  web.configs <system.web> section.

<pages maintainScrollPositionOnPostBack="true" />

Friday, November 21, 2008

Correct Date time for salesforce webservice


Correct Date time used for salesforce webservice to insert lead , Live sample C# Asp.net
SQL-SERVER:- SELECT CONVERT(VARCHAR(23), GETDATE(), 126)
C# Code:- DateTime.Now.ToString("yyyy-MM-ddThh:mm:ss-00:00"); 
Hardcoded:- 2008-11-21T04:37:14-05:00

Salesforce custom field error: - is not a valid value for the type xsd:dateTime

Error: '2008-09-06' is not a valid value for the type xsd:dateTime
Solution: I got correct result when inputting date format like this:-
2008-11-21T04:37:14-05:00

more on this issue :-

http://community.salesforce.com/sforce/board/message?board.id=NET_development&message.id=4069

CS0117: 'Default1.aspx' does not contain a definition for 'binding'- salesforce sample C# asp.net

CS0117: 'Default1.aspx' does not contain a definition for 'binding'- salesforce sample C# asp.net
use correct webreference, you have to use patnet webservice.

Compiler Error Message: CS0103: The name 'sfdc' does not exist in the current context - salesforce sample C# asp.net

Error 2: Compiler Error Message: CS0103: The name 'sfdc' does not exist in the current context - salesforce sample C# asp.net
Ans:  you are not using patner's webservice download that webservice and try again.

'sforce.sObject' does not contain a definition for 'Any'- salesforce sample C# asp.net

Error1: 'sforce.sObject' does not contain a definition for 'Any'- salesforce sample C# asp.net
you are not using patner's webservice download that webservice and try again.

Wednesday, November 19, 2008

Asp.net 2.0 login controls C# Access database sample code

Asp.net 2.0 login controls C# Access database sample code with connectionstring
 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
<!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>
                 <asp:Login ID="Login1" runat="server" OnAuthenticate="Login1_Authenticate"
        BackColor="Transparent" BorderColor="#ffccff" BorderPadding="4" BorderStyle="Solid"
        BorderWidth="0px" Font-Names="Verdana" Font-Size="10px" ForeColor="#333333"
        Height="53px" Width="100%"  >
            <TitleTextStyle BackColor="#507CD1" Font-Bold="True" Font-Size="0.9em" ForeColor="White"  />
            <InstructionTextStyle Font-Italic="True" ForeColor="Black" />
            <TextBoxStyle Font-Size="1.2em" />
            <LoginButtonStyle BackColor="White" BorderColor="#507CD1" BorderStyle="Solid" BorderWidth="1px"
                Font-Names="Verdana" Font-Size="12px" ForeColor="#284E98" />
            <LayoutTemplate>
                <table border="0" cellpadding="4" cellspacing="0" style="border-collapse: collapse; height: 99px;">
                    <tr>
                        <td  align="left">
                            <table border="0" cellpadding="0" style="width: 100%; height: 25%">
                                <tr>
                                    <td align="right">
                                        <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName" Font-Bold="True" ForeColor="White" Font-Size="10px">User Name:</asp:Label></td>
                                    <td align="left">
                                        <asp:TextBox ID="UserName" runat="server" Font-Size="10px" BackColor="#FFFFC0" Font-Bold="False"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
                                            ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right" style="height: 23px">
                                        <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password" Font-Bold="True" ForeColor="White" Font-Size="10px">Password:</asp:Label></td>
                                    <td align="left" style="height: 23px">
                                        <asp:TextBox ID="Password" runat="server" Font-Size="10px" TextMode="Password" BackColor="#FFFFC0" Font-Bold="False"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
                                            ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
                                        <asp:Button ID="LoginButton" runat="server" BackColor="White" BorderColor="#507CD1"
                                            BorderStyle="Solid" BorderWidth="1px" CommandName="Login" Font-Names="Verdana"
                                            Font-Size="11px" ForeColor="#284E98" Text="Log In" ValidationGroup="Login1" OnClick="LoginButton_Click" />
                                           
                                            </td>
                                </tr>
                                <tr>
                                    <td colspan="2" align="left">
                                        <asp:CheckBox ID="RememberMe" runat="server" Text="Remember me" Font-Bold="False" ForeColor="White"  />
                                        </td>
                                </tr>
                                <tr>
                                    <td align="center" colspan="2" style="color: red; height: 16px;">
                                        <asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
                                    </td>
                                </tr>
                            </table>
                            <strong><span style="color: #ffff33"></span></strong></td>
                    </tr>
                </table>
            </LayoutTemplate>
        </asp:Login>
   
    </div>
    </form>
</body>
</html>

-----
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;
public partial class login : System.Web.UI.Page
{
    string CaseIDClient;  
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        bool Authenticated = false;
        Authenticated = SiteLevelCustomAuthenticationMethod(Login1.UserName, Login1.Password);
        e.Authenticated = Authenticated;
        if (Authenticated == true)
        {
           Response.Redirect("dispcase.aspx");
/*
            if (Session["userRole"].ToString() == "client")
            {
                Response.Redirect("clientcasestatus.aspx?caseID=" + CaseIDClient);
            }
            else
            {
                Response.Redirect("dispcase.aspx");
            }
 */
        }
    }
    private bool SiteLevelCustomAuthenticationMethod(string UserName, string Password)
    {
        OleDbConnection conDatabase = null;
        OleDbDataReader Dr = null;
        bool boolReturnValue = false;
        string strUserID = UserName;
        conDatabase = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\\database\\testDB.mdb");
        conDatabase.Open();
        string strSQL = "select * from USERS where USERID=\'" + (strUserID + "\'");
        OleDbCommand cmdDatabase = new OleDbCommand(strSQL, conDatabase);
        Dr = cmdDatabase.ExecuteReader();
        while (Dr.Read())
        {
            string UserNameDB = Dr["USERID"].ToString();
            string PasswordDB = Dr["PASSWORD"].ToString();
            string userbranchDB = Dr["USERBRANCH"].ToString();
            string userRoleDB = Dr["ROLE"].ToString();
           

            if ((UserName == UserNameDB.TrimEnd().TrimStart()) & (Password == PasswordDB.TrimEnd().TrimStart()))
            {
                Session["loginm"] = strUserID;
                Session["userRole"] = userRoleDB;
                Session["userBranch"] = userbranchDB;
                Session["CaseIDClient"] = Dr["CASENO"].ToString();
                boolReturnValue = true;
                break;

            }
           
        }
        conDatabase.Close();
        Dr.Close();
        return boolReturnValue;
    }
   
    protected void LoginButton_Click(object sender, EventArgs e)
    {
    }
}

 

Tuesday, November 18, 2008

simple search parsing string by Split Method C# ASP.NET

Simple search parsing string by Split Method C# ASP.NET.


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="searchtest.aspx.cs" Inherits="searchtest" %>

<!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>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
    </form>
</body>
</html>

 

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;

public partial class searchtest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        char[] delimiterChars = { ' ', ',', '.', ':', '\t' };

     
        string text = TextBox1.Text;
     

        string[] words = text.Split(delimiterChars);

        Response.Write( words.Length);

        foreach (string s11 in words)
        {


            Response.Write(s11.ToString()+"<br />");


        }


    }
}

Monday, November 17, 2008

Asp.net Access database for optional search criteria or Where Condition Code Sample

Asp.net MS Access for optional search criteria or Where Condition


It similar to use COALESCE in access database, or passing null parameter to access database.






<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>


<!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>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" /><br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CASEID"
DataSourceID="AccessDataSource1">
<Columns>
<asp:BoundField DataField="CASEID" HeaderText="CASEID" InsertVisible="False" ReadOnly="True"
SortExpression="CASEID" />
<asp:BoundField DataField="CASEIDNO" HeaderText="CASEIDNO" SortExpression="CASEIDNO" />
<asp:BoundField DataField="SERVICEID" HeaderText="SERVICEID" SortExpression="SERVICEID" />

<asp:BoundField DataField="BANKNAME2" HeaderText="BANKNAME2" SortExpression="BANKNAME2" />
<asp:BoundField DataField="Days3Notice" HeaderText="Days3Notice" SortExpression="Days3Notice" />
<asp:BoundField DataField="SERVICEIDDESC" HeaderText="SERVICEIDDESC" SortExpression="SERVICEIDDESC" />
<asp:BoundField DataField="LOANNO" HeaderText="LOANNO" SortExpression="LOANNO" />
<asp:BoundField DataField="BRANCH" HeaderText="BRANCH" SortExpression="BRANCH" />
<asp:BoundField DataField="DTI" HeaderText="DTI" SortExpression="DTI" />
<asp:BoundField DataField="USERID" HeaderText="USERID" SortExpression="USERID" />
</Columns>
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" CancelSelectOnNullParameter="False"
runat="server" DataFile="C:\database\magestic.mdb"
SelectCommand="SELECT * FROM [CaseInfo] WHERE (@USERID IS NULL OR USERID LIKE '%' + @USERID + '%') and (@BRANCH IS NULL OR BRANCH LIKE '%' + @BRANCH + '%')" OnSelecting="AccessDataSource1_Selecting">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox1" Name="USERID" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="TextBox2" Name="BRANCH" PropertyName="Text" Type="String" />
</SelectParameters>
</asp:AccessDataSource>




</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;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void AccessDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
if (!IsPostBack)
{
e.Cancel = true;
}
}
}

Friday, November 14, 2008

C# Access Connection String live sample ASP.net

C# Access Database ConnectionString live sample ASP.net      

        string connectionString = "provider=Microsoft.Jet.OLEDB.4.0;data source=c:\\database\\xxxDB.mdb";
        OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);
        OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand();
       
        string Strsql = "SELECT  top 50 * from DetailUrl where ProdType='M2'";

        myOleDbCommand.CommandText = Strsql;
        myOleDbConnection.Open();

        OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader();

Create Rss Feed (Web service) using C# Asp.net Access database

Creating your own webservice (RSS feed) with access/mysql/sql-server database. following is the full code, where you can see how to create a rss feed using asp.net c# access database. first you have to create a project in visual studios 2005 as web service (.ashx) and use following code to build your feed. (live sample http://visli.com/rss.ashx)


<%@ WebHandler Language="C#" Class="rss" %>

using System;
using System.Web;
using System.Data.OleDb;
using System.Text;
using System.Xml;

public class rss : IHttpHandler {

    public void ProcessRequest(HttpContext context)
    {

        string sTxt = BuildXmlString();
        context.Response.ContentType = "text/xml";
        context.Response.ContentEncoding = System.Text.Encoding.UTF8;
        context.Response.Write(sTxt);
    }
        
  private string BuildXmlString()
    {
        string sTitle = "Super Value Deals and Deals of The Day";
        string sSiteUrl = "http://www.visli.com";
        string sDescription = "Super Value Deals and Deals of The Day";
        string sTTL = "60";

        System.Text.StringBuilder oBuilder = new System.Text.StringBuilder();
        oBuilder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        oBuilder.Append("<rss version=\"2.0\"><channel>");

        oBuilder.Append("<title>");
        oBuilder.Append(sTitle);
        oBuilder.Append("</title>");

        oBuilder.Append("<link>");
        oBuilder.Append(sSiteUrl);
        oBuilder.Append("</link>");

        oBuilder.Append("<description>");
        oBuilder.Append(sDescription);
        oBuilder.Append("</description>");

        oBuilder.Append("<ttl>");
        oBuilder.Append(sTTL);
        oBuilder.Append("</ttl>");


        AppendItems(oBuilder);


        oBuilder.Append("</channel></rss>");
        return oBuilder.ToString();
    }


    public void AppendItems(System.Text.StringBuilder oBuilder)
    {

        string connectionString = "provider=Microsoft.Jet.OLEDB.4.0;data source=c:\\xxxx\\database\\xxxxDB.mdb";
        OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);
        OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand();
        string ProdTy = "M2";
        string Strsql = "SELECT  top 50 * from DetailUrl where ProdType='M2'";

        myOleDbCommand.CommandText = Strsql;
        myOleDbConnection.Open();

        OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader();

        myOleDbDataReader.Read();
        while (myOleDbDataReader.Read())
        { 
        
        
            string sTitle = "Super Value Deals and Deals of The Day";
            string sLink = "http://www.visli.com/";
            string sDescription = "Super Value Deals and Deals of The Day";
            string sPubDate = "System.DateTime.Now";

            oBuilder.Append("<item>");

            oBuilder.Append("<title>");
            oBuilder.Append(myOleDbDataReader["TextUrl"].ToString());
            oBuilder.Append("</title>");

            oBuilder.Append("<link>");
            oBuilder.Append(myOleDbDataReader["NameUrl"].ToString());
            oBuilder.Append("</link>");
            
            oBuilder.Append("<description>");
            oBuilder.Append("&lt;img src=" + myOleDbDataReader["ImageUrl"].ToString() + "&gt;" + "&lt;br&gt;" + myOleDbDataReader["Price"].ToString() + "&lt;br&gt;visit  &lt;a href=http://www.visli.com&gt;http://www.visli.com&lt;/a&gt;");
            oBuilder.Append("</description>");

            oBuilder.Append("<pubDate>");
            oBuilder.Append(myOleDbDataReader["UpdDate"].ToString());
            oBuilder.Append("</pubDate>");

            oBuilder.Append("</item>");


        }
    }


    
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}

Thursday, November 13, 2008

Retriving page name in program like Default.aspx, Home.aspx - asp.net

Retriving page name in program like Default.aspx, Home.aspx

Request.Path.Substring(Request.Path.LastIndexOf("/") + 1)

 

Retrieving user Name on any page asp.net 2.0

string userName = Membership.GetUser().UserName;
using profile.UserName

JD Edwards - Sales Update Process - R42800

Sales Update serves four main purposes.                              
1. Updates the Financials systems by: 
Creating journal entries in the General Ledger (F0911) file. 
Creating receivable records in the Accounts Receivable (F0311/F03B11) file. 
2. Updates the item's on-hand quantity if not previously done by Shipment Confirmation (P4205). 
3. Closes out the sales order. 
4. Purges the sales order to history files if the processing options is set. 

Files Updates

1. Accounts Receivable (F0311/F03B11) and General Accounting (F0911) 
2. Inventory (F41021/F4111) 
3. Sales History (F4229) and Item History (F4115) 
4. Sales Commission (F42005) 
5. Sales Order Detail History (F42119) 
6. Sales Order Header History (F42019) 
7. Tax File (F0018) 
8. Sales Order Detail File (F4211) 
9. Media Objects storage (F00165) 
10. Price Adjustments History (F4074) 
11. Ship And Debit Claims (F4576) 


Can Sales Update (R42800) be re-run?                          

If sales update must be re-run, all of the files must be restored to the condition they were in prior to running sales update. For most clients, this means restoring the most recent backup media. All of the data entered prior to when the media was created will be available. However, the data processed after the media was created will need to be re-entered. This can include (but is not limited to) sales, purchasing, accounts payable, and general ledger information. This can involve a large amount of time.

Wednesday, November 12, 2008

UltraDev Cart - C# Shopping Cart Class

UltraDev Cart - C# Shopping Cart Class

Rewrite url with Masterpage & Intelligencia.UrlRewriter.dll in asp.net 2.0

I did following way to rewrite url with Masterpage & Intelligencia.UrlRewriter.dll asp.net 2.0


1.Copy Intelligencia.UrlRewriter.dll in bin folder


2. Put stylesheet as following:
<link href="style.css" rel="stylesheet" type="text/css" id="style1">
3.in Code behind put following code:
style1.Href = Page.ResolveUrl("~/style.css");

4. Your web.config will look like following

<?xml version="1.0"?>

<configuration>
  <configSections>
    <section name="rewriter" requirePermission="false"  type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
  </configSections>
  <system.web>
    <httpModules>
      <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
      
    </httpModules>
  </system.web>

    <rewriter>
      <rewrite url="~/products/(.+).aspx" to="~/products.aspx?category=$1&amp;prdty=$2" />
      <rewrite url="~/mainsearch/(.+)-(.+).aspx" to="~/mainsearch.aspx?URLID=$1&amp;prdty=$2" />
      <rewrite url="~/Default/(.+)-(.+)-(.+).aspx" to="~/Default.aspx?Pageno=$1&amp;URLID=$2&amp;prdty=$3" />
    </rewriter>

</configuration>

URL Rewriting Multiple Parameters using Asp.net 2.0 C#, web.config

URL Rewriting Multiple Parameters using Asp.net 2.0 C#, web.config

1> Download Intelligencia.UrlRewriter.dll copy to bin folder.
2> Create Web.config as following:

 

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="rewriter" 
             requirePermission="false"
             type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
  </configSections>
  <system.web>
    <httpModules>
      <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
    </httpModules>
 </system.web>
  <rewriter>
    <rewrite url="~/products/(.+).aspx" to="~/products.aspx?category=$1" />
    <rewrite url="~/mainsearch/(.+)/(.+).aspx" to="~/mainsearch.aspx?URLID=$1&amp;prdty=$2" />
  </rewriter>
 
</configuration>
 
products page is for 1 parameter mainsearch is for 2 parameters.

Monday, November 10, 2008

Saturday, November 8, 2008

JD Edwards Convert Julian Date to Normal (Gregorian) Date vice versa

Normal Date to Julian Date
declare @rpdivj as int
declare @datea as datetime
set @rpdivj='102015'
set @datea= DATEADD(dy, @rpdivj % 1000, DATEADD(yy, @rpdivj / 1000,-1))
print DATEADD(dy, @rpdivj % 1000, DATEADD(yy, @rpdivj / 1000, -1))
print DATEPART(month, @datea)
print DATEPART(day, @datea)
print DATEPART(year, @datea)
--Julian Date to Normal Date
declare @y as varchar(10)
declare @dy as varchar(10)
declare @date1 as datetime
declare @szupmj as varchar(10)
set @date1= getdate()--'10/01/02'
-- set @date1= '10/1/2002'
set @y =(datepart(yy,@date1) - 1900) * 1000;
set @dy = datepart(dy,@date1);
set @szupmj = @y + cast(@dy as int);
print 'Date ====>>> '+ @szupmj
in Select Statement
DATEADD(dy, cast(SDTRDJ as varchar(10)) % 1000, DATEADD(yy, cast(SDTRDJ as varchar(10)) / 1000,-1))
select (datepart(yy,getdate()) - 1900) * 1000+ cast(datepart(dy,getdate())as int)
select CONVERT(CHAR(15),GETDATE(),101)

Thursday, November 6, 2008

Gridview with Checkbox Live sample

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID"
            DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"
                    ReadOnly="True" SortExpression="ProductID" />
                <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
                <asp:BoundField DataField="SupplierID" HeaderText="SupplierID" SortExpression="SupplierID" />
                <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" SortExpression="CategoryID" />
        <asp:TemplateField HeaderText="Select">
            <ItemTemplate>
               <asp:CheckBox ID="chkSelect" runat="server" />
            </ItemTemplate>
        </asp:TemplateField>
            
            </Columns>
            
        </asp:GridView>
        &nbsp;
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
        <asp:Label ID="Label1" runat="server" Width="218px"></asp:Label>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            SelectCommand="SELECT [ProductID], [ProductName], [SupplierID], [CategoryID] FROM [Alphabetical list of products]">
        </asp:SqlDataSource>
    </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.Text;
//using System.Text;

public partial class Default4 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text = "";
        StringBuilder str = new StringBuilder();

        // checkboxes from the GridView control
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            GridViewRow row = GridView1.Rows[i];
            bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked;

            if (isChecked)
            {
                //ProductID
                str.Append(GridView1.Rows[i].Cells[0].Text);
             
            }
                
                 if (!isChecked)
                 {
                     Label1.Text = "Please Select One...";
                 }

        }
        Response.Write(str.ToString());

        
    }
}

Tuesday, November 4, 2008

CodeProject: Adding custom assemblies in SQL Server Reporting Services 2005. Free source code and programming help

CodeProject: Adding custom assemblies in SQL Server Reporting Services 2005. Free source code and programming help

How to Manually Create a Typed DataTable.

CodeProject: How to Manually Create a Typed DataTable. Free source code and programming help

Cosmos - C# Open Source Managed Operating System.

CodeProject: Cosmos - C# Open Source Managed Operating System. Free source code and programming help

Cosmos?
Cosmos is short for C# Open Source Managed Operating System. Despite C# being in the name, VB.NET, Fortran, and any .NET language can be used. We chose the C# title because our work is done in C#, and VBOSMOS just does not sound as nice.
Cosmos is not an Operating System in the traditional sense, but instead, it is an "Operating System Kit", or as I like to say "Operating System Legos", that allows you to create your own Operating System. However, having been down this path before, we wanted to make it easy to use and build. Most users can write and boot their own Operating System in just a few minutes, and using Visual Studio.
Cosmos lets Visual Studio compile your code to IL and then Cosmos compiles the IL into machine code.