Thursday, December 3, 2009
Friday, November 20, 2009
How to use Google Map in ASP.NET
The Javascript:
<head runat="server">
<title>Google map Page</title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAA6TS6WR4jbbUjikFVO_rihBSsoQeukxbo2NPugNeooGWFf_yQhRSk4JGGBtb5COzcswcwgPpu5XJo3Q"
type="text/javascript"></script>
<script type="text/javascript">
var map=null;
var Head = 'style="color:White;background-color:#339900;font-family:Verdana;font-size:11px;font-weight:bold;"';
var Data = 'style="background-color:#ffff99;font-family:Verdana;font-size:11px;overflow:auto; "';
var gmarkers = [];
var ghtml = [];
var m = 0;
function load()
{
if (GBrowserIsCompatible())
{
var LatitudePoint='<%= LatitudePoint %>';
var LongitudePoint='<%= LongitudePoint %>';
var RestaurantName='<%= RestaurantName%>';
var RestaurantAddress='<%=RestaurantAddress%>';
var map = new GMap(document.getElementById("map"));
var point = new GPoint(LatitudePoint,LongitudePoint);
map.addControl(new GLargeMapControl());
map.setCenter(new GLatLng(LatitudePoint,LongitudePoint), 5 );
function createMarker(point,Html)
{
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function()
{
//marker.openInfoWindowHtml('<div class="infodescription">'+Html+'</div>');
marker.openInfoWindowHtml(Html);
});
return marker;
}
var request = GXmlHttp.create();
request.open("GET", "parks.xml", true);
request.onreadystatechange = function()
{
if (request.readyState == 4)
{
var xmlDoc = request.responseXML;
var points = xmlDoc.documentElement.getElementsByTagName("park");
for (var i = 0; i < points.length; i++)
{
var point = new GPoint(LongitudePoint,
LatitudePoint);
var cHtml = '<table cellspacing=0 cellpading=0 border=1>' +
'<tr>' +
'<td align="center">' + RestaurantName + '</td>' +
'</tr>'+
'<tr>' +
'<td>' + RestaurantAddress + '</td>' +
'</tr>' +
'</table>';
var marker = createMarker(point,cHtml);
map.addOverlay(marker);
marker.openInfoWindowHtml(cHtml);
}
}
}
request.send(null);
}
}
</script>
</head>
<body onload="load()">
<form id="form1" runat="server">
<div>
<div id="map" style="width: 700px; height: 590px;">
</div>
</div>
</form>
</body>
The XML File: (parks.xml)
<parks>
<park FullName="Test" address="8,GN Road" lng="80.2385401725769" lat="13.048898223457536"/>
<park FullName="Birds Fort Trail Park" address="575 North Usman Road" lng="80.2496401725769" lat="13.059898223457536"/>
</parks>
Asp.Net C# Coding:
public string LatitudePoint = "12.916051";
public string LongitudePoint = "80.024414";
public string RestaurantName = "Rangish";
public string RestaurantAddress = "";
public string strRestaurantID = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
LatitudePoint = "70.5896";
LongitudePoint = "80.2568";
RestaurantName = "Test Name";
RestaurantAddress = "Dharapuram";
}
}
Monday, July 13, 2009
image Insert & Select
string strImageFileExt;
string imageName;
if (fuProductImage.FileName.ToString().Trim() != "")
{
strImageFileExt = fuProductImage.FileName.Substring(fuProductImage.FileName.LastIndexOf(".") + 1).ToLower();
imageName = ddlMovieName.SelectedItem.Text.Trim()+ "." + strImageFileExt;;
Save(imageName);
}
string strtest = "insert into Abirami_MovieDetails values('" + ddlMovieName.SelectedItem.Text.Trim() + "','" + imageName + "')";
SqlCommand sqlCmd = new SqlCommand(strtest, conn);
sqlCmd.ExecuteNonQuery();
Save Image Function:
private void Save(string imageName)
{
if (imageName != null && imageName.Trim() != "")
{
System.Drawing.Image objImage = null;
if (fuProductImage.HasFile)
{
objImage = System.Drawing.Image.FromStream(fuProductImage.FileContent);
System.Drawing.Image objSmallImage = objImage.GetThumbnailImage(161, 206, objTIA, IntPtr.Zero);
objSmallImage.Save(Server.MapPath("../AbiramiImages/" + imageName.Trim().Replace(" ", " ").Replace(" ", "_").Replace(":", "_").Replace("(", "_").Replace(")", "_")));
}
}
}
select:
SqlCommand cmd = new SqlCommand("select V_MovieProducer,V_MovieDirector,V_MovieMusicDirector,V_MovieWriter,V_MovieCast,V_MovieImage,V_Synopsis,V_StartDate,V_EndDate from Abirami_MovieDetails where V_MovieName='" + ddlMovieName.SelectedItem.Text.Trim() + "'", conn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
txtProducer.Text = dr["V_MovieProducer"].ToString();
strImage = "../AbiramiImages/" + dr["V_MovieImage"].ToString().Trim();
if (System.IO.File.Exists(Server.MapPath(strImage)) == true)
{
Image1.ImageUrl = strImage;
}
else
{
Image1.ImageUrl = "../MovieImages/Image_Not_Available.gif";
}
}
dr.Close();
Thursday, July 9, 2009
Stored Procedure code in DAL
{
MySqlCommand cmd = new MySqlCommand("LMT_GetReport", Conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("?DD_StartDate", MySqlDbType.Datetime);
cmd.Parameters["?DD_StartDate"].Value = dStartDate;
cmd.Parameters.Add("?DD_EndDate ", MySqlDbType.Datetime);
cmd.Parameters["?DD_EndDate "].Value = dEndDate;
cmd.Parameters.Add("?VV_ScreenName ", MySqlDbType.VarChar, 50);
cmd.Parameters["?VV_ScreenName "].Value = strScreenName;
cmd.Parameters.Add("?VV_ShowTime ", MySqlDbType.VarChar, 50);
cmd.Parameters["?VV_ShowTime "].Value = strShowTime;
DataSet ds = new DataSet();
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
da.Fill(ds);
return ds;
}
One Textbox assign Multible Button value
this code will help...
in Design part Button Event Click event give btnTickets_Click
Web Application:
protected void lnkShowDate_Click(object sender, EventArgs e)
{
string str = ((System.Web.UI.WebControls.LinkButton)(sender)).ToolTip;
}
Windows:
private void btnTickets_Click(object sender, EventArgs e)
{
txtTicket.Text = ((System.Windows.Forms.ButtonBase)(sender)).Text;
}
Wednesday, June 24, 2009
Get Multi row in Single Coloum using C#.Net Code
public string strTransactionNumber1 = "";
public string strTransactionNumber2 = "";
public string strSeatNo = "";
DataTable dtData = new DataTable();
dtData.Columns.Add("TransactionNumber");
dtData.Columns.Add("UserName");
dtData.Columns.Add("TransactionDate");
dtData.Columns.Add("ShowDate");
dtData.Columns.Add("ShowTime");
dtData.Columns.Add("MovieName");
dtData.Columns.Add("SeatName");
dtData.Columns.Add("TotalTickets");
dtData.Columns.Add("Per Seat Price");
dtData.Columns.Add("Limata Amount");
dtData.Columns.Add("Client Amount");
dtData.Columns.Add("Name");
dtData.Columns.Add("MobileNumber");
dtData.Columns.Add("EmailID");
dtData.Columns.Add("IDCardType");
dtData.Columns.Add("IDCardInfo");
DataTable dt = new DataTable();
DataSet dsReport = new DataSet();
OtherBLL objReport = new OtherBLL();
dsReport = objReport.GetTheatreReport(Convert.ToDateTime(txtStartDate.Text), Convert.ToDateTime(txtEndDate.Text), 146, ddlShowTime.SelectedItem.Text);
if (dsReport.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < dsReport.Tables[0].Rows.Count; i++)
{
dt = dsReport.Tables[0];
DataRow dr;
dr = dtData.NewRow();
if (i > 0)
strTransactionNumber1 = dt.Rows[i - 1]["V_TransactionNumber"].ToString();
strTransactionNumber2 = dt.Rows[i]["V_TransactionNumber"].ToString();
if (strTransactionNumber1 == strTransactionNumber2)
{
strSeatNo += "," + dt.Rows[i]["V_SeatName"].ToString();
}
else
{
strSeatNo = dt.Rows[i]["V_SeatName"].ToString();
}
dtData.Rows.Add(dt.Rows[i]["V_TransactionNumber"].ToString(), dt.Rows[i]["V_UserName"].ToString(), dt.Rows[i]["D_TransactionDate"].ToString(), dt.Rows[i]["D_ShowDate"].ToString(), dt.Rows[i]["V_ShowTime"].ToString(), dt.Rows[i]["V_MovieName"].ToString(), strSeatNo, dt.Rows[i]["N_TotalTickets"].ToString(), dt.Rows[i]["C_SeatPrice"].ToString(), dt.Rows[i]["LimataAmount"].ToString(), dt.Rows[i]["F_TotalPrice"].ToString(), dt.Rows[i]["V_CardHolderName"].ToString(), dt.Rows[i]["V_MobileNumber"].ToString(), dt.Rows[i]["V_EmailID"].ToString(), dt.Rows[i]["V_IDCardType"].ToString(), dt.Rows[i]["V_IDCardInfo"].ToString());
// dtData.Rows.Add(dt.Rows[i]["V_TransactionNumber"].ToString(), dt.Rows[i]["D_ShowDate"].ToString(), dt.Rows[i]["V_ShowTime"].ToString(), dt.Rows[i]["V_MovieName"].ToString(), dt.Rows[i]["N_TotalTickets"].ToString(), dt.Rows[i]["F_TotalPrice"].ToString(), strSeatNo);
if (i > 0)
{
if (dt.Rows[i - 1]["V_TransactionNumber"].ToString() == dt.Rows[i]["V_TransactionNumber"].ToString())
{
int iCount = dtData.Rows.Count - 1;
dtData.Rows[iCount - 1].Delete();
}
}
dtData.AcceptChanges();
}
grdReport.Visible = true;
lblMessage.Visible = false;
Session["DataSet"] = dtData;
grdReport.DataSource = dtData;
grdReport.DataBind();
Thursday, June 18, 2009
Get Multi row in Single Coloum using SQL Query & Check 2 value in same colume
(select (select TD.V_SeatName as col1 FROM Transaction T where TD.N_TransactionID=T.N_TransactionID
for xml raw, elements, type).query('for $col1 in (row/col1) return concat($col1, ",")')) as SeatName
Check 2 value in same colume:(Get Status for (1 or 4))
select * from testtable where N_Status in(1,4)
Monday, May 11, 2009
Negative to Postive Value
string s = "-123.45";
s = Math.Abs(Convert.ToDouble(s)).ToString();
//Output=123.45
Saturday, May 9, 2009
Date Time Format
string=strStartDate;
strStartDate = Convert.ToDateTime(strStartDate).ToString("yyyy/MM/dd");
Tuesday, March 10, 2009
.Net Short Cut Keys
Ctrl + KU - UnCommanted
Ctrl + KD - Allignment
Ctrl + G - Go To Line
Find Browser Using Java Script
<script type="text/javascript">
var browser=navigator.appName;
if(browser=="Microsoft Internet Explorer")
{
}
else if(browser=="Netscape")
{
}
</script>
Sunday, February 8, 2009
Find IP Address in ASP.NET
if (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != "" && Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)
strIPAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
else if (Request.ServerVariables["REMOTE_ADDR"] != "" && Request.ServerVariables["REMOTE_ADDR"] != null)
strIPAddress = Request.ServerVariables["REMOTE_ADDR"];
Response.Write("Your IP " + strIPAddress);
Thursday, February 5, 2009
Serial number column in a Gridview at runtime
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" >
<Columns>
<asp:TemplateField HeaderText="S.No">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Thursday, January 29, 2009
slide show in java script(image changing)
<html>
<head>
<script language="JavaScript1.1">
var slidespeed=2500
var slideimages=new Array("theatre1.jpg","theatre2.jpg","theatre3.jpg", "theatre4.jpg","theatre5.jpg","theatre6.jpg","theatre7.jpg","theatre8.jpg")
var newwindow=0 //open links in new window? 1=yes, 0=no
var imageholder=new Array()
var ie=document.all
for (i=0;i<slideimages.length;i++)
{
imageholder[i]=new Image()
imageholder[i].src=slideimages[i]
}
function gotoshow()
{
if (newwindow)
window.open(slidelinks[whichlink])
else
window.location=slidelinks[whichlink]
}
//-->
</script>
</head>
<body bgcolor="#AF5996">
<a href="javascript:gotoshow()"><img src="theatre1.jpg" name="slide" border=0 style="filter:blendTrans(duration=3)" width=180 height=200 align="center"></a>
<script language="JavaScript1.1">
<!--
var whichlink=0
var whichimage=0
var blenddelay=(ie)? document.images.slide.filters[0].duration*1000 : 0
function slideit(){
if (!document.images) return
if (ie) document.images.slide.filters[0].apply()
document.images.slide.src=imageholder[whichimage].src
if (ie) document.images.slide.filters[0].play()
whichlink=whichimage
whichimage=(whichimage<slideimages.length-1)? whichimage+1 : 0
setTimeout("slideit()",slidespeed+blenddelay)
}
slideit()
//-->
</script>
</body>
</html>
Monday, January 26, 2009
Data List Paging
<div>
<asp:DataList ID="dlCountry" runat="server">
<ItemTemplate>
<asp:Label ID="Label1" runat="server"
Text='<%# Eval("V_TransactionNumber") %>'></asp:Label>
<asp:Label ID="Label2" runat="server"
Text='<%# Eval("V_MobileNumber") %>'></asp:Label>
</ItemTemplate>
</asp:DataList>
<asp:LinkButton ID="lnkbtnPrevious" runat="server" OnClick="lnkbtnPrevious_Click1"><<</asp:LinkButton>
<asp:LinkButton ID="lnkbtnNext" runat="server" OnClick="lnkbtnNext_Click1">>></asp:LinkButton>
</div>
IN ASPX.CS:
SqlConnection con = new SqlConnection("Server=PAT105;Database=LimataWeb;User ID=sa;Password=acconline;");
PagedDataSource pds = new PagedDataSource();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
public int CurrentPage
{
get
{
if (this.ViewState["CurrentPage"] == null)
return 0;
else
return Convert.ToInt16(this.ViewState["CurrentPage"].ToString());
}
set
{
this.ViewState["CurrentPage"] = value;
}
}
private void BindGrid()
{
string sql = "Select * from [Transaction] Order By N_TransactionID";
SqlDataAdapter da = new SqlDataAdapter(sql, con);
DataTable dt = new DataTable();
da.Fill(dt);
pds.DataSource = dt.DefaultView;
pds.AllowPaging = true;
//pds.PageSize = Convert.ToInt16(ddlPageSize.SelectedValue);
pds.PageSize = Convert.ToInt16("5");
pds.CurrentPageIndex = CurrentPage;
lnkbtnNext.Enabled = !pds.IsLastPage;
lnkbtnPrevious.Enabled = !pds.IsFirstPage;
dlCountry.DataSource = pds;
dlCountry.DataBind();
}
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
CurrentPage = 0;
BindGrid();
}
protected void lnkbtnNext_Click1(object sender, EventArgs e)
{
CurrentPage += 1;
BindGrid();
}
protected void lnkbtnPrevious_Click1(object sender, EventArgs e)
{
CurrentPage -= 1;
BindGrid();
}
Friday, January 23, 2009
Pop Up Window
<a onclick="javascript:window.open('../index.htm','mywindow','top=10,left=10,width=700,height=500, toolbar=no,location=yes,directories=yes,status=yes,menubar=no,scrollbars=yes,copyhistory=no, resizable=no')">Terms And Conditions</a>
Response.Write("<script>window.open('ContactUs.aspx','List','scrollbars=no, resizable=no,width=400,height=280');</script>");
Java Script:
<script type="text/javascript" language="javascript">
function poponload()
{
testwindow= window.open ("Default.aspx", "mywindow",
"location=1,status=1,scrollbars=1,width=100,height=100");
testwindow.moveTo(0,0);
(OR)
window.open ("http://www.javascript-coder.com","mywindow");
}
</script>
<asp:Button ID="Button2" runat="server" Text="Button" OnClientClick="return poponload();" />
just add on onunload event in <BODY> Tag <body onunload="javascript: poponload()" >
Link: http://www.javascript-coder.com/window-popup/javascript-window-open.phtml