Thursday, July 30, 2009

Different ways of reading and writing text file data in .NET

Different ways of reading and writing text file data in .NET

Dynamically Generate Meta Tags for ASP.NET Pages using LINQ To XML

Dynamically Generate Meta Tags for ASP.NET Pages using LINQ To XML

Url Rebasing in ASP.NET 2.0

Url Rebasing in ASP.NET 2.0: ASP Alliance: "Url Rebasing"

Let’s say we have an image control with relative path on the masterpage html, and Masterpage is in one folder and the content page is in different folder. The relative image path given in the masterpage html markup points to the wrong location and the image is not rendered. To avoid these sorts of problems Asp.Net rebases relative urls known as Url Rebasing.

Thursday, July 23, 2009

Rss Feed to Listview with DataPager in Asp.net

Displaying Rss Feed in  Listview also using DataPager in Asp.net sample.
 
 
<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="feedtolistview.aspx.cs" Inherits="feedtolistview" %>

<!

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 id="Head1" runat="server">

<title>Using DataPager and ListView Controls with a Custom Data Source</title>

</

head>

<

body>

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

<div>

<asp:DataPager ID="dataPager" runat="server" PagedControlID="listItems" QueryStringField="page"

PageSize="5" >

<Fields>

<asp:NextPreviousPagerField FirstPageText="&lt;&lt;" ShowFirstPageButton="True"

ShowNextPageButton="False" ShowPreviousPageButton="False" />

<asp:NumericPagerField />

<asp:NextPreviousPagerField LastPageText="&gt;&gt;" ShowLastPageButton="True"

ShowNextPageButton="False" ShowPreviousPageButton="False" />

</Fields>

</asp:DataPager>

<br />

<asp:ListView ID="listItems" runat="server" DataSourceID="xmlDataSource">

<LayoutTemplate>

<asp:PlaceHolder runat="server" ID="itemPlaceholder" />

</LayoutTemplate>

<ItemTemplate>

<h3><a href="<%# XPath("link") %>"><%# XPath("title") %></h3> </a>

<%

# XPath("description")%>

</ItemTemplate>

<ItemSeparatorTemplate>

<hr />

</ItemSeparatorTemplate>

</asp:ListView>

<asp:XmlDataSource ID="xmlDataSource" runat="server" DataFile="http://rss.news.yahoo.com/rss/topstories"

XPath="rss/channel/item"></asp:XmlDataSource>

<asp:DataPager ID="dataPager1" runat="server" PagedControlID="listItems" QueryStringField="page"

PageSize="5">

<Fields>

<asp:NumericPagerField />

</Fields>

</asp:DataPager>

</div>

</form>

</

body>

</

html>

Friday, July 17, 2009

Find String within string C#

int FirstChr = MainString.IndexOf(SearchString);
 

Thursday, July 16, 2009

Date formating at gridview

DataFormatString

="{0:dd-MM-yyyy}"

Connection string based on the Database Environment c#

 Connection string based on the Database Environment c# sample:
 
<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<

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

<

head runat="server">

<title>Untitled Page</title>

</

head>

<

body>

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

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

<div>

<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">

</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"

ProviderName="System.Data.SqlClient"

DataSourceMode="DataReader"

SelectCommand="SELECT * FROM [mntsold]"></asp:SqlDataSource>

</div>

</form>

</

body>
</
html>
 

using

System;

using

System.Data;

using

System.Configuration;

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 _Default : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

if (System.Environment.GetEnvironmentVariable("COMPUTERNAME").ToString() == "xxxxxxx")

{

Response.Write(

"from test database");

SqlDataSource1.ConnectionString =

ConfigurationManager.ConnectionStrings["JDE_RKConnectionString"].ConnectionString;

}

if (System.Environment.GetEnvironmentVariable("COMPUTERNAME").ToString() == "ITWEB1223")

{

Response.Write(

"from production database");

SqlDataSource1.ConnectionString =

ConfigurationManager.ConnectionStrings["JDE_PRODUCTIONConnectionString"].ConnectionString;

}

 

}

}

SQLdatasource Connection String in code behind c#

<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">

</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"

ProviderName="System.Data.SqlClient"

DataSourceMode="DataReader"

SelectCommand="SELECT * FROM [mntsold]"></asp:SqlDataSource>

code behind:

SqlDataSource1.ConnectionString =

ConfigurationManager.ConnectionStrings["JDE_PRODUCTIONConnectionString"].ConnectionString;

web.config

<

connectionStrings>

<

add name="JDE_PRODUCTIONConnectionString" connectionString="Data Source=ENTERPRISE;Initial Catalog=JDE_PRODUCTION;User ID=sssss;password=sssss"

providerName="System.Data.SqlClient" />

</
connectionStrings>



Machine Name in code behind C#

string name = System.Environment.GetEnvironmentVariable("COMPUTERNAME");

Wednesday, July 8, 2009

Find the SQL Server CD key Installed in your PC Using SQL command

USE master
EXEC xp_regread 'HKEY_LOCAL_MACHINE',
                'SOFTWARE\Microsoft\Microsoft SQL Server\80\registration', 
                 'CD_KEY'

Tuesday, July 7, 2009

Selecting unique node in a RSS feed base on user selection using c# asp.net

Selecting unique node in a RSS feed base on user selection using  c# asp.net

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default10.aspx.cs" Inherits="Default10" %>
<!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:GridView ID="bank" Runat="server" DataSourceID="xds" AutoGenerateColumns="false" AllowPaging="True"  >
<Columns>

<asp:TemplateField>   
<ItemTemplate>       
<%# Container.DataItemIndex + 1 %>   
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
       <a href='Default10.aspx?url1=<%# Container.DataItemIndex + 1 %>'  >
          <%#XPath("title")%></a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:XmlDataSource ID="xds" Runat="server" DataFile="http://rss.news.yahoo.com/rss/topstories"
>
</asp:XmlDataSource>
   
    </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 Default10 : System.Web.UI.Page
{
    string strURL;
    protected void Page_Load(object sender, EventArgs e)
    {
       // Response.Write(Request["url1"].ToString());

        if (Request["url1"] == null)
        {
            xds.XPath = "rss/channel/item [position()>=0]";
            //strURL = "1";
        }
        else
        {
            //xds.XPath = "rss/channel/item [position()=" + Request["url"] + "]";
            strURL = Request["url1"];
            xds.XPath = "rss/channel/item [position()=" + strURL + "]";
        }

       

    }
}

Add items in menu by role with fine cut - JD Edwards E1

Master view ->click on fine cut-> click on blank space and select view by role-> select the role

and add menu item -> after that agaion change the role to admin-> click on fine cut

RSS feed particular Item display in a gridview

<div>

<asp:GridView ID="bank" Runat="server" DataSourceID="xds" AutoGenerateColumns="False" AllowPaging="True" >

<

Columns>

<

asp:TemplateField>

<

ItemTemplate>

<asp:HyperLink ID="HyperLink1" Runat="server" Text='<%# XPath("title") %>' NavigateUrl='<%# XPath("link") %>'

Target="_blank" Font-Names="Verdana" Font-Size="X-Small">

</asp:HyperLink>

</

ItemTemplate>

</

asp:TemplateField>

</

Columns>

</

asp:GridView>

<

asp:XmlDataSource ID="xds" Runat="server" DataFile="http://rss.news.yahoo.com/rss/topstories"

XPath

="rss/channel/item [position()=2]">

</

asp:XmlDataSource>

</div>

Thursday, July 2, 2009

Compiler Error CS1705

Compiler Error CS1705

Auto Page refresh Sample Using C#, Ajax

Auto Page refresh Sample Using  C#, Ajax
 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="autoreferesh.aspx.cs" Inherits="autoreferesh" %>

<!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">
     <asp:Label ID="Label2" runat="server" Text="This is Time, When The Full Page Load :" Font-Bold="true"></asp:Label>&nbsp;
     <asp:Label ID="MyLabel" runat="server"></asp:Label><br /><br />       
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div>
            <asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="30000">
            </asp:Timer>
        </div>
        <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
            </Triggers>
            <ContentTemplate>
                <asp:Label ID="Label3" runat="server" Text="This is The Time when Page will Referesh :" Font-Bold="true"></asp:Label>&nbsp;
                <asp:Label ID="Label1" runat="server" Text="Page not refreshed yet."></asp:Label><br />
                <asp:Label ID="Label4" runat="server" Text="(Page Will Referesh after Every 30 Sec)" Font-Bold="true"></asp:Label>&nbsp;
                <br /><br />
            </ContentTemplate>
        </asp:UpdatePanel>     
    </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 autoreferesh : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        MyLabel.Text = System.DateTime.Now.ToString();
    }
    protected void Timer1_Tick(object sender, EventArgs e)
    {

        Label1.Text = "Page Refreshed at: " + DateTime.Now.ToLongTimeString();

    }


}