Loading...
Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Saturday, 27 July 2013

// // Leave a Comment

Maintenance Complete in Download Center

Hi,

We have finished migrating all thing from Previous Host to New Host. Download Center is expected to Work as same as previous days. Accounts registered with our website has been kept same and you can log in with earlier credential. Other URLs and Bookmarks you added will also remain same and working.


However, Live FM's will be down for some more hours. We are working and collecting more reliable sources of stream. Once it will be done, we will notify you here.

You can keep in touch by Adding us on Facebook page, Just hit Like and Click Show in Feed link which will appear on hovering Like Button. You can also subscribe to new songs on Download Center  via Feedburner Service by Google. Google will drop you a mail once New Song is available on Download Center.

We have shifted to Higher Configuration and Dedicated Server without any Limitations, So Website is expected to load in less time and other resources also.

Till then, enjoy New songs in Download Center and have fun.


Regards,
+John Bhatt & Team
P.Yar.B Complex
Read More

Thursday, 23 May 2013

// // Leave a Comment

New Version of Srijan Shiksha Website

Hi Friends,

We have recently modified the Core of Srijan Shiksha Website. Now it is an example of Best Websites of Organizations. Please have a look at below link.

http://www.srijanshiksha.com/

This is completely responsive website for Different Platforms. We expect it to display well and Fit on every platform.

Desktop Browser View is as below:


Android Browser:

Have a look and give feedback. We will be waiting to hear from you.

Till then you can add me on Google+, My profile is +John Bhatt 

Read More

Sunday, 21 April 2013

// // Leave a Comment

New Year Gift

Hey Friends,

I still remember those days, honestly and clearly speaking, starting days of my Internet Experience. I have some knowledge of Website Designing. I have learn HTML at Modern Computer Education before heading towards India approximately for 2-3 months. I use to read a book by Hemanta Baral named Manuals for  Masters In Computer Application,
While I have started to learn about the Web Technology, one of Marketing Company Reserved this Domain and offered me for the cost of 1500 USD. I was definitely not in position to grab the offer. So Finally on the First Day of Year 2070, I registered my Nick Name as Website. Now Live at www.pyarb.com.

Happy New Year 2070....

Meanwhile, you can connect me on Google+ and My Profile is +John Bhatt and You can Find Hemanta sir at +Hemanta Baral.
Read More

Saturday, 6 October 2012

// // 1 comment

Accordion Panel with CSS

Greetings from John!,
Hope you all are enjoying.
Friends I am back with a new thing for you. Today I am going to show you, how to make a Good Accordion Panel.

Do you know, what is Accordion Panel? You must have seen some tables or Div's in website, that are collapsing and expanding on just Click. You can also call them Collapsible Div or Table.

ASP.NET Ajax Tools make it so Simpler for ASP.NET. You just need to link AjaxControlToolkit.dll to your bin folder and use it in the Page.
Let's add a new Web Form in Solution, this is the Page, where you want to add your collapsible div or table what may contain anything.

Source Code for Design above is here.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Accordian with CSS >> P.Yar.B Complex</title>
<%--<link href="Accordian.css" rel="stylesheet" />--%>
</head>

<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<table width="100%" border="0">
<tr>
<td colspan="2" align="center">
<h1>Accordian with CSS</h1>
</td>
</tr>
<tr>
<td colspan="3" align="center">
<asp:Accordion ID="Accordion1" runat="server" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent" Width="490px">
<Panes>
<asp:AccordionPane ID="pane1" runat="server">
<Header>Hardwares</Header>
<Content>
Mouse<br />
KeyBoard<br />
Monitor
<br />
Printer<br />
CPU<br />
Speakers<br />
Camera
</Content>
</asp:AccordionPane>
<asp:AccordionPane ID="pane2" runat="server">
<Header>Operating System</Header>
<Content>
MS Windows<br />
Linux<br />
Android<br />
Mac<br />
Unix
</Content>
</asp:AccordionPane>
<asp:AccordionPane ID="pane3" runat="server">
<Header>.NET IDE</Header>
<Content>
Visual Studio<br />
Visual Web Developer<br />
SharpDevelop<br />
MonoDevelop
</Content>
</asp:AccordionPane>
<asp:AccordionPane ID="pane4" runat="server">
<Header>John Bhatt</Header>
<Content>
<a href="http://www.johnbhatt.com" target="_blank">Portal Home</a><br />
<a href="http://blog.johnbhatt.com" target="_blank">Blog of P.Yar.B</a><br />
<a href="http://media.johnbhatt.com" target="_blank">Download Center</a><br />
</Content>
</asp:AccordionPane>
</Panes>
</asp:Accordion>
</td>
</tr>
</table>
</form>
</body>
</html>


Now Let's See the CSS, what is on CSS.

.accordionHeader {
border: 1px solid #2F4F4F;
color: white;
background-color: #2E4d7B;
font-family: Arial, Sans-Serif;
font-size: 12px;
font-weight: bold;
padding: 5px;
margin-top: 5px;
cursor: pointer;
}

#master_content .accordionHeader a {
color: #FFFFFF;
background: none;
text-decoration: none;
}

#master_content .accordionHeader a:hover {
background: none;
text-decoration: underline;
}

.accordionHeaderSelected {
border: 1px solid #2F4F4F;
color: white;
background-color: #5078B3;
font-family: Arial, Sans-Serif;
font-size: 12px;
font-weight: bold;
padding: 5px;
margin-top: 5px;
cursor: pointer;
}

#master_content .accordionHeaderSelected a {
color: #FFFFFF;
background: none;
text-decoration: none;
}

#master_content .accordionHeaderSelected a:hover {
background: none;
text-decoration: underline;
}

.accordionContent {
background-color: #D3DEEF;
border: 1px dashed #2F4F4F;
border-top: none;
padding: 5px;
padding-top: 10px;
}

Now Run the Page again. Lets See, how it looked. Check this at your machine. Best of Luck!
Read More

Tuesday, 18 September 2012

// // Leave a Comment

File Upload Control with File Type Filter

Hi,

We are going to learn how to upload a File using FileUpload Control in ASP.NET.

ASPX Code

We Placed a FileUpload Control and a button to Click.

<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="BtnUpload" runat="server" Text="Upload File" onclick="BtnUpload_Click" />

Back-end Code

Now BtnUpload_Click event in .cs page.
We are going to Upload only Picture (.JPG file or .BMP file).
 
protected void BtnUpload_Click(object sender, EventArgs e)
{
string sSiteFolder = "ResumeFolder";
string sRealPath = Server.MapPath(sSiteFolder);
if (!Directory.Exists(sRealPath))
Directory.CreateDirectory(sRealPath);
string CompletePath = sRealPath + FileUpload1.FileName;
string FileExt = CompletePath.Substring(CompletePath.IndexOf("."));
switch (FileExt)
{
case ".jpg":
FileUpload1.SaveAs(sRealPath + FileUpload1.FileName);
break;
case ".JPG":
FileUpload1.SaveAs(sRealPath + FileUpload1.FileName);
break;
case ".bmp":
FileUpload1.SaveAs(sRealPath + FileUpload1.FileName);
break;
case ".BMP":
FileUpload1.SaveAs(sRealPath + FileUpload1.FileName);
break;
}
}
Enjoy...
John Bhatt
Read More

Wednesday, 12 September 2012

// // Leave a Comment

Pagination with DataList

Hi,
As we know, DataList is the most versatile Data Bound Control available in ASP.NET. Where you can display data as per your need in your required style, direction etc.
But there is some problem also. There is no option to Paginate the Data Loaded in DataList directly. In case we have too many records, we can not display all them in One Page without paginating.

To escape from this situation, Developers move to GridView, which has easy support for Paginating data.

Today, we will learn How to Paginate DataList data in Simple steps.


First create a DataList as per your requirement. I made like below which is quite simple.





Lets place Next and Previous Buttons for Navigation. Code for above design is below:

Code in ASPX Page (Design)

<asp:DataList ID="DataList1" runat="server" Height="194px" Width="174px"
oneditcommand="DataList1_EditCommand"
oncancelcommand="DataList1_CancelCommand"
onupdatecommand="DataList1_UpdateCommand" DataKeyField="eno">
<HeaderTemplate>

<table width="450" border="2">
<tr>
<th>Employee Name </th>
<th>Designation </th>
<th>Salary </th>
<th>
Edit
</th>
</tr>

</HeaderTemplate>
<EditItemTemplate>
<tr>
<td>
<asp:TextBox ID="txtEname" Text='<%#Eval("ename")%>' runat="server" />
</td>
<td>
<asp:TextBox ID="txtJOb" Text='<%#Eval("job")%>' runat="server" />
</td>
<td>
<asp:TextBox ID="txtSal" Text='<%#Eval("sal")%>' runat="server" />
</td>
<td>
<asp:LinkButton ID="lnk2" runat="server" Text="Update" CommandName ="Update" />
</td>
<td>
<asp:LinkButton ID="LinkButton1" runat="server" Text="Cancel"
CommandName ="Cancel" />
</td>
</tr>

</EditItemTemplate>
<ItemTemplate>
<tr>
<td><%#Eval("ename")%></td>
<td><%#Eval("job")%></td>
<td><%#Eval("sal")%></td>
<td>
<asp:LinkButton ID="lnk1" CommandName="Edit" Text="Edit !" runat="server" />
</td>
</tr>

</ItemTemplate>

<FooterTemplate>
</table>
</FooterTemplate>
</asp:DataList>
<br />
<table class="style1">
<tr>
<td class="style2">
<asp:LinkButton ID="LinkButton2" runat="server" onclick="LinkButton2_Click">Next</asp:LinkButton>
</td>
<td>
<asp:LinkButton ID="LinkButton3" runat="server" onclick="LinkButton3_Click">Previous</asp:LinkButton>
</td>
</tr>
</table>




Now Lets to to Backend. ASPX.CS Page (Code Behind):





protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CurrentPageIndex = 0;
showData();
}
}
int pg = 0;
void showData()
{
PagedDataSource pgd = new PagedDataSource();
SqlDataAdapter da = new SqlDataAdapter("select * from emp", "Data Source=.\\SQLDB;Database=Test1;Integrated Security=True");
DataSet ds = new DataSet();
da.Fill(ds);

pgd.DataSource = ds.Tables[0].DefaultView;
pgd.CurrentPageIndex = CurrentPageIndex ;
pgd.AllowPaging = true;
pgd.PageSize = 5;

LinkButton2.Enabled = !(pgd.IsLastPage);
LinkButton3.Enabled = !(pgd.IsFirstPage);


DataList1.DataSource = pgd;
DataList1.DataBind();

}

protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)
{
DataList1.EditItemIndex = e.Item.ItemIndex;
showData();
}
protected void DataList1_CancelCommand(object source, DataListCommandEventArgs e)
{
DataList1.EditItemIndex = -1;
showData();
}
protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e)
{

}

public int CurrentPageIndex
{
get
{
if (ViewState["pg"] == null)
return 0;
else
return Convert.ToInt16(ViewState["pg"]);
}
set
{
ViewState["pg"] = value;
}
}

protected void LinkButton2_Click(object sender, EventArgs e) {
CurrentPageIndex++;
showData();
}
protected void LinkButton3_Click(object sender, EventArgs e)
{
CurrentPageIndex--;
showData();
}




Now Let me Describe things happened in above code:




Move to showData() function.








We created a new object of PagedDataSource. Paged data source as name stands clear, paginated data.





Now we wrote Query, Passed in Adapter, Filled DataSet which should be all clear, because it was Basic Task in ADO.NET. Now we gave it CurrentPageIndex. means where is page now.








For this, just look below to a class CurrentPageIndex which is returning value of CurentPageIndex =0 if page is beling Loaded. To check whether page is loaded or postback, we take help of ViewState. If ViewState["pg"] == null, On Page load this will be null because it is just being initiated. On Postback it will pass the Int value stored in it to CurrentPageIndex.








We set Pagination in PagedDataSource true and Define Page size of 5 records per page.


Now Passed PagedDataSource object as Datasource of Datalist.








Now Linkbutton click events, We increased and Decreased value of CurrentPageIndex.








Hope this must be helpful to you. In case of Any problem, correction in code and help, feel free to comment below.





John Bhatt




Glad to Know, Free to Share.....





http://www.johnbhatt.com





Read More

Thursday, 6 September 2012

// // 1 comment

Rich Text Editor with ASP.NET


Introduction


As we know, ASP.NET lack a Control, that we need most, RichText Editor. 

If you are trying to create a application or website with Admin Panel or Blog or Forum Website or something such project for Web in ASP.NET platform, we need RickText Editor. 

To overcome from this, we can use Many open source JavaScript based editors, like Tiny MCE, FCKEditor, etc.

Content:

In this Article, we would learn how to Implement Free RichText Editor into ASP.NET website. We are using TinyMCE editor here.

We are using TinyMCE, which is One of most popular and Open Source project. Download latest version of TinyMCE from Download Page, and Extract the Zip File.


Browse the Extracted Location and go to ..\tinymce_3.5.6\tinymce\jscripts folder.

Now Copy the tinymce folder from above Location to your Solution in Visual Studio.


Add a Page where you want to Implement RichTextbox and Design the Page.


Now lets Move to Topic. How to Add TinyMCE in Page and Richtext box Control placed for Content of Blog in above sample.

Insert JavaScript file tiny_mce.js in Web Page and some also initialize this function.

This Code into head Section.

 
<script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" language="javascript">
tinyMCE.init({
// General options
mode: "textareas",
theme: "advanced",
plugins: "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups",
});
</script>
Note: You can so many settings, look in Samples and Help Doc of TinyMCE.

Now Run the Page. Look, how it looked.



Without any additional Practice, our TextBox with Multiline turned into RichText Editor.

Now, its ok as per Requirement. No, when you will send Command to Server, it will return Error Like below.


We have to add just One Line of Code in Web.config file and one property in Default.aspx form (Page with Rich Text Editor).

That is : 

in web.config:

<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpRuntime requestValidationMode="2.0"/>
</system.web>
</configuration>

and in Page directive:

ValidateRequest = "false"

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" ValidateRequest="false" %>

Now, you can save the Data in Database, Do postback, retrieve same in Rich Text box and do anything you want.

Conclusion


IT is Jugad. So enything is possible here. Don't be worry about things that are not available. Just modify and make use of things those are available. Tiny MCE is one of the most known and Popular Rich Text editor (WYSIWYG).

You can find many more articles written by me on Dotnetspider also. Have a look at them.
You can add me to your Circle on Google+ at +John Bhatt

Hope this will be helpful to you. 
Read More

Wednesday, 29 August 2012

// // Leave a Comment

Implement Same WebMethod for AutoComplete in Multiple Textbox

Hi,


While Answering a question at Forum, I wrote this post.


Suppose We have Multiple Textbox in Same Page and we want to Implement AutoSuggest/AutoComplete feature in All Textbox and of same type. Suppose Multiple Google Search Boxes.


For that case, we have separate Textboxs, Separate AutoComplete Extenders and Separate Methods. We are trying to Consume same PageMethod in All Textbox.


Front End Code:

Product One:


DelimiterCharacters="" Enabled="True" ServiceMethod="GetProducts" MinimumPrefixLength="2"
ServicePath="" TargetControlID="TextBox1" UseContextKey="True">

Product Two:


DelimiterCharacters="" Enabled="True" ServicePath="" TargetControlID="TextBox2"
ServiceMethod="GetProducts" MinimumPrefixLength="2" UseContextKey="True">

Product Three:


DelimiterCharacters="" Enabled="True" ServicePath="" TargetControlID="TextBox3"
ServiceMethod="GetProducts" MinimumPrefixLength="2" UseContextKey="True">




BackEnd Code:


[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public static string[] GetProducts(string prefixText, int count, string contextKey)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConToStore"].ConnectionString);
SqlDataAdapter adp = new SqlDataAdapter("Select * from Products where UnitsInStock>0 and ProductName like '%" + prefixText + "%'", con);
DataSet ds = new DataSet();
adp.Fill(ds);
string[] Products = new string[ds.Tables[0].Rows.Count];
for (int j = 0; j <= ds.Tables[0].Rows.Count - 1; j++)
{
Products.SetValue(ds.Tables[0].Rows[j][1].ToString(), j);
}
return Products;
}
Lets Look at the Output.

Hope this will be Helpful.
John Bhatt
Glad to Know, Free to Share.....
http://www.johnbhatt.com

Read More

Saturday, 18 August 2012

// // Leave a Comment

DropDownList (Country-State-District-City)

How to Make a Complete Dropdown and Prevent Inserting Dummy Data from Form.
Disable other Controls when Clicked back to Parent Control:
Drop Down Sequence:
OnLoad
Load Country
On-Change
Load State according to Country
On-Change
Load Dists in State
On-Change
List Cities in Dist.

Code:
protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
{
ddlState.DataSource = res.States(Convert.ToInt16(ddlCountry.SelectedValue));
ddlState.DataTextField = "StateName";
ddlState.DataValueField = "StateID";
ddlState.DataBind();
ddlState.Items.Insert(0, "Select");
ddlDist.Enabled = false;
ddlCity.Enabled = false;
}

protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)
{
ddlDist.DataSource = res.Districts(Convert.ToInt16(ddlState.SelectedValue));
ddlDist.DataTextField = "DistName";
ddlDist.DataValueField = "DistID";
ddlDist.DataBind();
ddlDist.Items.Insert(0, "Select");
ddlDist.Enabled = true;
ddlCity.Enabled = false;
}

protected void ddlDist_SelectedIndexChanged(object sender, EventArgs e)
{
ddlCity.DataSource = res.Cities(Convert.ToInt16(ddlDist.SelectedValue));
ddlCity.DataTextField = "CityName";
ddlCity.DataValueField = "CityID";
ddlCity.DataBind();
ddlCity.Items.Insert(0, "Select");
ddlCity.Enabled = true;
}
John Bhatt
Glad to Know, Free to Share.....
http://www.johnbhatt.com
Read More

Saturday, 7 July 2012

// // Leave a Comment

State Management in ASP.NET part-1 (Cookies)

Hi,

I am Back with State Management Series.

In this post we are going to Talk about Cookies. After Reading this, you must be able to do following things:
  • Create Cookie
  • Access Cookie
  • Can answer Some Basic Q & A about Cookie
What is Need of Cookie?

Cookies are Required to Store Temporary data in Users system which may be Required during Session or after Session.

How Many Type of Cookie are there?
Cookies are generally of Two Type. Session wide or Persistent. Sessional cookies Expire as soon as User Closed Session means Browser. Persistent cookies expire after Defined Time. This can be Defined at the Time of Creation.

Who Make Cookies?

Cookie is always made by Application (Server) in Users/ Clients Browser and stored in Hard Disk of User. These are used to store Users Customized Appearance, other Values , Login Time etc for future Retrieval so that website can server him better.

Limitations of Cookie?

Cookies are open Invitations to Hackers.

Cookies can only store Little and Only String Type Data.



Now Lets Learn with Coding. First We will Create a Cookie named myCookie and Solve Earlier Problem with the Help of Cookie.
Now Code is Like Below:
protected void Page_Load(object sender, EventArgs e)
{

}
int x; // Made a Variable with Datatype Int for Future Use
HttpCookie myCookie; // Defined a Cookie named myCookie.
protected void Button1_Click(object sender, EventArgs e)
{
x = Convert.ToInt32(TextBox1.Text); // Converted textbox Value which we earlier Did.
myCookie = new HttpCookie("txtValue"); // Assigned Variable myCookie.
myCookie.Value = Convert.ToString(x); // Value assigned to myCookie.
Response.Cookies.Add(myCookie); //This Simple Made a Cookie that will Expire in Session End.
myCookie.Expires = DateTime.Now.AddMinutes(15); // We made is Persistent and stored it for Next 15 minutes.

}
protected void Button2_Click(object sender, EventArgs e)
{

HttpCookie storedCook = Request.Cookies["txtValue"]; // Requested from Server for Cookie
if (storedCook != null)
x = Convert.ToInt32(storedCook.Value); // Converted to Integer again.
TextBox1.Text = Convert.ToString(x * x); // Now Printed Value in Textbox.
}
Now Check....

Don't forget to add me on Google+, +John Bhatt .
Read More
// // Leave a Comment

State Management in ASP.NET

Hi Everybody,


I am once back with a blog/article/tutorial whatever you think/call it.


State Management :


HTTP Protocol is State less protocol. In Simple Language, Each and Every time We send a request to server, this is New to server.

To Understand this ,Suppose you took One Textbox and Two Buttons like in Image below:



Now, the task is To Enter Number in Textbox and Click in First Button to Convert to Integer format and then Click Second button to Print Square of Converted Integer in Textbox. What will you do. Lets look at code what I did here.

protected void Page_Load(object sender, EventArgs e)
{

}
int x;

protected void Button1_Click(object sender, EventArgs e)
{
x = Convert.ToInt32(TextBox1.Text);
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = Convert.ToString(x * x);
}


Now what would I get Result on Second Button Click event. Textbox Result will be 0 even I have entered any number. Don't agree, try this at home.


This is Because, at the time of Button2 Click new request is send to server and Initial Value of X is picked from server which is 0.


To Prevent the Loose of Data each time we send request to server, ASP.NET have implemented concept of State Management.

State Management is divided into 2 parts according to Functionality.

1) User Based State Management
  • Cookies
  • QueryStrings
  • ViewState
  • Controls
  • Hidden Fields
2) Server Based State Management
  • Session
  • Application
  • Profile


I am going to Describe all these States step by step in Different Posts.

All the Series has been posted on DotNetSpider at below Link Resources > Keep Reading.
Read More

Thursday, 5 July 2012

// // Leave a Comment

AutoCompleteExtender in Textbox

Hi,

We will learn how to enable AutoCompleteExtender in Textbox Control.


Here, We will learn to Map data from SQL Database to Textbox within Same Page. WebMethod in .cs Page.

Directly to Code:
ASPX Page Code



Vehicle No :










Now Code in ASPX.CS Page

Add these Namespages for below Code.
using System.Data; // For Dataset
using System.Data.SqlClient; // For SQlConnection/Adaptor
using System.Configuration; // Access Consting from Web.Config.
using System.Collections.Generic;



[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public static string[] GetVehicleList(string prefixText, int count, string contextKey)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConToJohn"].ConnectionString);
SqlDataAdapter adp = new SqlDataAdapter("Select distinct VehicleNo from VehicleDispatch where VehicleNo like '%" + prefixText + "%'", con);
DataSet ds = new DataSet();
adp.Fill(ds, "Vehicles");
string[] VehicleNo = new string[ds.Tables["Vehicles"].Rows.Count];
for (int i = 0; i <= ds.Tables["Vehicles"].Rows.Count - 1; i++)
{
VehicleNo.SetValue(ds.Tables["Vehicles"].Rows[0][0].ToString(), i);
}
return VehicleNo;
}
I have Selected Only Unique Value from Database using SELECT DISTINCT .... command. If you want all records, Simply Change SQL Query to SELECT ..... Will be glad to hear from you... This Post is copied from DotNetFunda where I wrote in Code section.
Read More

Thursday, 28 June 2012

// // Leave a Comment

Opening a Webpage according to Textbox Value

Hi,

Today I am going to tell you, how to Open a Web Page according to TextBox Value in ASP.NET. You can implement same in Plain HTML Page. This will use a Simple JavaScript Function which we will create according to our need.
Lets Look at the Code. We are using ASP.NET Ajax AutoCompleteExtender for more enhancement in Code (This will only work in ASP.NET).
Code for ASPX Page (HTML Design Part - ASP.NET)

 






If you are using Plain HTML, Just use this code.
 


Now JavaScript Code which is Inserted Directly in Head Section. (JavaScript)





Now code for C# page if you are using AutoComplete Extender.
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]

public static string[] GetCompletionList(string prefixText, int count, string contextKey)

{

string[] Brands = { "hp", "acer", "dell", "lenovo" };

return (from m in Brands where m.StartsWith(prefixText, StringComparison.CurrentCultureIgnoreCase) select m).Take(count).ToArray();

}
Enjoy...
Read More

Friday, 22 June 2012

// // Leave a Comment

Export to Excel from DataGridView in ASP.NET

Hi,
We are going to learn how to Export GridView data to Microsoft Excel at Runtime.

We are using: ASP.NET Framework 4.0, Visual Studio 2010, SQL Server 2008, C#, XHTML 4.01

 Code for ASPX Page (Front-End) Adding GridView and Columns:

&LTasp:GridView ID="gvPros" runat="server" AutoGenerateColumns="false" Width="664px" Font-Names="Calibri"
HeaderStyle-Font-Bold="true" AlternatingRowStyle-BackColor="LightGoldenrodYellow" EmptyDataText="No Records Found. Try again by Changing Filter Options."&GT
&LTColumns&GT
&LTasp:TemplateField HeaderText="Party Name"&GT
&LTItemTemplate&GT
&LTasp:Label ID="lblPartyName" runat="server" Text='&LT%#Eval("PartyName")%&GT'&GT&LT/asp:Label&GT
&LT/ItemTemplate&GT
&LT/asp:TemplateField&GT
&LT/Columns&GT
&LTColumns&GT
&LTasp:TemplateField HeaderText="Mode"&GT
&LTItemTemplate&GT
&LTasp:Label ID="lblFreight" runat="server" Text='&LT%#Eval("Division")%&GT'&GT&LT/asp:Label&GT
&LT/ItemTemplate&GT
&LT/asp:TemplateField&GT
&LT/Columns&GT
&LTColumns&GT
&LTasp:TemplateField HeaderText="Month"&GT
&LTItemTemplate&GT
&LTasp:Label ID="lblMonthName" runat="server" Text='&LT%#Eval("ProMonth")%&GT'&GT&LT/asp:Label&GT
&LT/ItemTemplate&GT
&LT/asp:TemplateField&GT
&LT/Columns&GT
&LTColumns&GT
&LTasp:TemplateField HeaderText="Total Box"&GT
&LTItemTemplate&GT
&LTasp:Label ID="lblTotalBox" runat="server" Text='&LT%#Eval("ProPkg")%&GT'&GT&LT/asp:Label&GT
&LT/ItemTemplate&GT
&LT/asp:TemplateField&GT
&LT/Columns&GT
&LTColumns&GT
&LTasp:TemplateField HeaderText="Actual Weight"&GT
&LTItemTemplate&GT
&LTasp:Label ID="lblPartyName" runat="server" Text='&LT%#Eval("ProActWt")%&GT'&GT&LT/asp:Label&GT
&LT/ItemTemplate&GT
&LT/asp:TemplateField&GT
&LT/Columns&GT
&LTColumns&GT
&LTasp:TemplateField HeaderText="Charged Wt"&GT
&LTItemTemplate&GT
&LTasp:Label ID="lblChWt" runat="server" Text='&LT%#Eval("ProChWt")%&GT'&GT&LT/asp:Label&GT
&LT/ItemTemplate&GT
&LT/asp:TemplateField&GT
&LT/Columns&GT
&LTColumns&GT
&LTasp:TemplateField HeaderText="Freight"&GT
&LTItemTemplate&GT
&LTasp:Label ID="lblFreight" runat="server" Text='&LT%#Eval("ProFreight")%&GT'&GT&LT/asp:Label&GT
&LT/ItemTemplate&GT
&LT/asp:TemplateField&GT
&LT/Columns&GT
&LT/asp:GridView&GT

Adding Export Link
 &LTasp:LinkButton ID="lnkExport" runat="server" Text="Export to Excel" onclick="lnkExport_Click"&GT&LT/asp:LinkButton&GT

Now Code for ASPX.CS Page (BackEnd):


Namespaces :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Drawing;
using System.IO;
using System.Text;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;

Data Binding and Export LinkButton Click Event:
void GVProsFill()
{
string Query = "Select * from Parties, Prosperity where Parties.PartyID=Prosperity.ProParty";
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConToSEPL"].ConnectionString);
SqlDataAdapter adp = new SqlDataAdapter(Query, con);
DataSet ds = new DataSet();
adp.Fill(ds);
gvPros.DataSource = ds.Tables[0];
gvPros.DataBind();
}

//You have to add an another Event for Export to work properly:
public override void VerifyRenderingInServerForm(Control control)
{
// Can Leave This Blank.
}

protected void lnkExport_Click(object sender, EventArgs e)
{
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Prosperity.xls"));
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gvPros.AllowPaging = false;
GVProsFill();
gvPros.HeaderRow.Style.Add("background-color", "#FFFFFF");
for (int a = 0; a < gvPros.HeaderRow.Cells.Count; a++)
{
gvPros.HeaderRow.Cells[a].Style.Add("background-color", "#507CD1");
}
int j = 1;
foreach (GridViewRow gvrow in gvPros.Rows)
{
gvrow.BackColor = Color.White;
if (j <= gvPros.Rows.Count)
{
if (j % 2 != 0)
{
for (int k = 0; k < gvrow.Cells.Count; k++)
{
gvrow.Cells[k].Style.Add("background-color", "#EFF3FB");
}
}
}
j++;
}
gvPros.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}

I will be waiting to Listen from you....
Read More

Thursday, 24 May 2012

// // Leave a Comment

First HTML Page

We will Now start Creating a Web page with HTML.


To Learn Coding with HTML, Lets learn some Basic Rules.
  • Entire Page is contained inside and tag.
  • HTML Web Document is Seperated in two parts. Head and Body. Head starts Just after HTML with and closes with contents with tag. Head is where where Brain Lies means all Scripts, styles, and Meta Tags are Written Inside Head tag. As soon tag is closed tag is started to Open Body of HTML Page. Body is Place where you can put your Design and Data. This is directly responsible for Display or Look or Design (Web Page). After Writing Body of Web Page tag is closed with just before tag.


Lets have an Example.


Open your Favorite Text Editor (Mostly Love Notepad, I also):

Type Below Code







This is Our First HTML Web Page.





Steps Now in Brief:


First I wrote





bacause I want to create a HTML Document.


Then I put Head in HTML Document, because I want to Write some Code in Head Section. I added Body to HTML Document. I wrote a Paragraph between

and

tags. Note these Tags are Accepted only inside Body. Now Source Code is:




This is Our First HTML Web Page.





After Coding this in Notepad or Any other Text Editor, Choose Save from File Menu or Press CTRL+S to Save File. Name your File and Put a estension .html or .htm. If you do not type this Extension, File is Saved as Just Text with File Extension .txt and that will not be a HTML Web Page.


Read More

Friday, 26 August 2011

// // Leave a Comment

Filling Background in a page

Dear All,
This is to tell you that how to insert background color and image in a webpage.
For Filling Color as Background
We use bgcolor attribute with body tag. Here is an example showing that how to fill color.


<br /> Webpage with Background Color<br />


This page will have Red color as its background.



Click here for preview. Page With Background Color
For Inserting Image as Background
We use background attribute with body tag. Here is an example showing that how to insert image as background.This page will have my photos as its background.
Read More

Wednesday, 17 August 2011

// // Leave a Comment

First Web page

Hello! Welcome Back,

Now open the notepad by Typing notepad in Run
Run command.
Now type the following codes in notepad and save it with extension .htm or .html.



<br />First HTML Page<br />


Anything you want to display in the website, you are allowed to write here.

....

....

........




Now I am going to describe the above codes.
First we started with tag which starts the HTML language. This is to identify that the script is written in HTML for Web-Browsers. Then we started tag which is used to write scripts and for advance level use. Then we started tag. This is the title of page which is written in Title Bar of Browser. Then we closed tag using forward slash . Then we also closed tag using forward slash . Now our header area is closed and we have to start body of web page with  tag. We can write anything we want to display in the webpage inside body area. After writing the body contents we have to close  tag with . And we closed all HTML tags by the help of tag.
In brief these are the most important tags to create a webpage.
Visit next post for next chapter.
Read More

Sunday, 31 July 2011

// // Leave a Comment

HTML Codes/ Tags


Hi,
I have introduced you with HTML in my earlier post. Now we will start creating HTML files. i.e. Web Pages.
HTML is scripting language which is written in codes, called tags. These tags are written inside angle brackets (<>).
These tags are of two types.
1) Container Tag: Also called Paired Tags. These tags have endings also. These tags are closed with forward slash (/). eg. …..,
….
etc.
2) Empty Tag: Also known as single tag. These tags do not have endings. Eg.

,
etc.
Read More
// // Leave a Comment

HTML Introduction


HTML is a Programming Language. It’s full form is Hyper Text Markup Language.
This language is invented by Swish Physician Tim Berners-Lee in 1990 AD at European Laboratory, Switzerland.
Definition:
HTML is a simple scripting language used to create hypertext documents. Hyper text document is a piece of text that works as link.
Before HTML, it was SGML which is abbreviation of Standard Generated Markup Language.
Read More