15,914,066 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by promod madushan (Top 116 by date)
promod madushan
27-Mar-14 5:39am
View
my php code is wrong? function?
promod madushan
27-Mar-14 5:37am
View
Deleted
i think my php function page is wrong?
this is my submit button
<span class="button-3">
send
</span>
if i write a php code like?
if onClick==submit { code; }
is it okay?
promod madushan
26-Feb-14 8:23am
View
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Full Error?
What is this and how i resolved this?
promod madushan
26-Feb-14 8:20am
View
sql exception unhandled
Login failed for user ''.
this is the error
still occurs? :(
promod madushan
19-Feb-14 22:35pm
View
That's okay...
but how can i refer body part for following code?
<img src="images/bg.jpg" alt="" id="background" />
is it?
<img src="body" alt="" id="background" />
promod madushan
5-Feb-14 20:52pm
View
<asp:ContentPlaceHolder ID="Stylesheets" runat="server">
<link rel="stylesheet" href="/css/StyleSheet.css" type="text/css" />
I Declared like this in my master page?
body
{
font: "Trebuchet MS", Verdana, sans-serif;
background-color: #5c87b2;
color: #696969;
}
this is my css file's content?
promod madushan
5-Feb-14 11:42am
View
yeah i know, but i declared in css file my child page to be in blue background? but when i compile it, it doesn't show any blue background
promod madushan
5-Feb-14 10:26am
View
now i created a new child page and i compiled it and still shows me blank page
promod madushan
5-Feb-14 10:18am
View
So that means if erased my child page's code.. still my master page is correct or not?
promod madushan
5-Jan-14 1:27am
View
thanks for the reply..
but i gave 250 know? so textbox will be longer than other textbox.
but all the textboxes remain same?..
promod madushan
6-Dec-13 7:22am
View
Thanks Mate!!
promod madushan
6-Dec-13 6:44am
View
I did as it says? but still same problem?
do u konw any good ide for PHP?
promod madushan
14-Nov-13 22:08pm
View
Deleted
i'm using c# controls?
the concept is there are two combo boxes and one textbox, two radio buttons..
Usertype = Combobox
Username = Combobox
PAssword = Textbox
New user = Radio button
Excisting user = Radio button
this application for small company
there are two usertypes = HR and IT
if some one select hr... it will load all the usernames from the database which related to HR.. so as IT users
if user select new user radio button... one textbox will visible to new users to password authentication
other thing is if user select existing user radio button
it will compare user input password with database one and gives user to access
promod madushan
14-Nov-13 21:16pm
View
if (NewUserRB.Checked)
{
Pass_Verification.Visible = true;
if (User_Password.Text == Pass_Verification.Text)
{
String UserTypeCmb = UserType_CMBbox.SelectedItem.ToString();
String UserNameCmb = UserName_CMBbox.SelectedItem.ToString();
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=PROMOD-PC;Initial Catalog=Unicella_Data;Integrated Security=True";
con.Open();
String QueryStr1 = "UPDATE Login_Table SET Password=@PS WHERE User_Type=@UT AND User_Name=@UN";
SqlCommand cmd = new SqlCommand(QueryStr1, con);
cmd.Parameters.AddWithValue("@UT", UserTypeCmb);
cmd.Parameters.AddWithValue("@UN", UserNameCmb);
cmd.Parameters.AddWithValue("@PS", User_Password.Text);
cmd.ExecuteNonQuery();
MessageBox.Show("Password Succeed!");
}
I modified my previous code into this.
but nothing happened...
i connected sql database and combo box will load data from database.
but password not going to store
promod madushan
13-Nov-13 1:29am
View
thank you Ron (y)
promod madushan
6-Nov-13 14:37pm
View
Deleted
This solution gives this Error?
"Object reference not set to an instance of an object."
Code:-
String Usertype = UserType_CMBbox.SelectedValue.ToString();
promod madushan
2-Oct-13 11:41am
View
Thanks for the help. But Would you mind Please explain me bit!!!
promod madushan
27-Jul-13 3:44am
View
so for that i need select query to check and insert query to insert data?
i did't use update query because
it will only do the remove current data and store new data in the database
promod madushan
27-Jul-13 3:42am
View
in my interface ... there are two textboxes and user can input values to that textboxes.
so according to my program user can add comment to particular source and destination.
so i want to check user inputs are exist in the database and if exist then only they can add comments?
promod madushan
27-Jul-13 3:38am
View
if i do like this
RouteDetails.Text = sqldread2["Bus_Route"].ToString();
it will give an answer...
but i want to get two column details into one textbox
promod madushan
27-Jul-13 3:33am
View
it still gives me error in final code...
RouteDetails.Text = sqldread2["Bus_Route" + " Cost "].ToString();
error...
says
Bus_Route Cost
promod madushan
27-Jul-13 3:28am
View
how to do this kind of a problem?
promod madushan
27-Jul-13 2:51am
View
please give me any example for that?
promod madushan
27-Jul-13 2:26am
View
i want to inser data?
because if i do update.... it will remove my previous data know....
if i put insert it will store one by one and
i can access all at once?
if i do update i will be able to store only 1 data only
promod madushan
26-Jul-13 23:58pm
View
i think my whole part of second select query is wrong? may be
promod madushan
26-Jul-13 23:57pm
View
executenonquery error
promod madushan
26-Jul-13 3:31am
View
String selQuery = "SELECT Id FROM MapDataImage WHERE Source='" + Source_Box.Text + "' AND Destination='" + Distance_Box.Text + "'";
{
// call another sql command
scmd1 = new SqlCommand(selQuery, conn2);
SqlDataAdapter adp=new SqlDataAdapter(scmd1);
DataTable dt=new DataTable();
adp.Fill(dt);
conn2.Open();
still not working my friend.
promod madushan
23-Jul-13 2:13am
View
Please tell me a possible way to do this?
promod madushan
23-Jul-13 2:12am
View
okay? but i tested it?
no errors now.....
but not adding to the database too
promod madushan
15-Jul-13 17:55pm
View
this is not a textbox... this is texarea........
promod madushan
15-Jul-13 17:14pm
View
mate i think we cant use .text to read text area values?
UserComment.InnerText;
how about that..........
promod madushan
15-Jul-13 17:04pm
View
yeap.............
i have teatarea called User_Comment
promod madushan
15-Jul-13 11:15am
View
now i want to access val1 and val2 in login class?
how i do that?
promod madushan
15-Jul-13 10:13am
View
public partial class Login : System.Web.UI.Page
{
public void Button1_Click(object sender, EventArgs e)
{
String Strt_Address = TextBox1.Text;
String End_Address = TextBox2.Text;
SampleMethod(Strt_Address, End_Address);
}
}
namespace SampleNamespace
{
class SampleClass
{
public void SampleMethod(string val1, string val2)
{
System.Console.WriteLine(
"SampleMethod inside SampleNamespace");
}
}
}
the question is i want to get those string value in to SampleClass
so u mean without using
SampleMethod(Strt_Address, End_Address); this method and
class SampleClass
{
public void SampleMethod(string val1, string val2)
{
string val11 = val1;
string val12 = val2;
}
}
without using this just call like
login txt = new login();
string abc = txt.StrtAddress
like dat know
promod madushan
15-Jul-13 9:52am
View
didn't gt it?
promod madushan
15-Jul-13 9:47am
View
mate if i create separate class file...
then how i get those sting values to that class
promod madushan
15-Jul-13 9:43am
View
means?
//this is my class
namespace SampleNamespace
{
class SampleClass
{
public void SampleMethod(string val1, string val2)
{
System.Console.WriteLine(
"SampleMethod inside SampleNamespace");
}
}
}
SampleMethod(Strt_Address, End_Address);
// this is my value passing method
promod madushan
15-Jul-13 9:21am
View
public void Button1_Click(object sender, EventArgs e)
{
String Strt_Address = TextBox1.Text;
String End_Address = TextBox2.Text;
SampleMethod(Strt_Address, End_Address);
}
}
its like this
promod madushan
15-Jul-13 9:20am
View
i have classes like this
public partial class Login : System.Web.UI.Page
{
public void Button1_Click(object sender, EventArgs e)
{
SampleMethod(Strt_Address, End_Address);
}
}
namespace SampleNamespace
{
class SampleClass
{
public void SampleMethod(string val1, string val2)
{
System.Console.WriteLine(
"SampleMethod inside SampleNamespace");
}
}
}
like this................
promod madushan
15-Jul-13 9:08am
View
i did like this
SampleMethod(Strt_Address, End_Address);
//class
namespace SampleNamespace
{
class SampleClass
{
public void SampleMethod(string val1, string val2)
{
System.Console.WriteLine(
"SampleMethod inside SampleNamespace");
}
}
}
it still gives me error saying SampleMethod is not in current context
promod madushan
15-Jul-13 8:19am
View
thing is i have some values from out side out side
String Strt_Address = TextBox1.Text;
String End_Address = TextBox2.Text;
i gave a if condition to check if the textbox is null or not
if (Strt_Address != null)
{
sLong1 = geocodeXmlDoc1.DocumentElement.SelectSingleNode(@"//geometry/location/lat", XmlMngr1).InnerText;
sLat1 = geocodeXmlDoc1.DocumentElement.SelectSingleNode(@"//geometry/location/lng", XmlMngr1).InnerText;
sLong2 = geocodeXmlDoc2.DocumentElement.SelectSingleNode(@"//geometry/location/lat", XmlMngr2).InnerText;
sLat2 = geocodeXmlDoc2.DocumentElement.SelectSingleNode(@"//geometry/location/lng", XmlMngr2).InnerText;
Label1.Text = sLong1 + ", " + sLat1;
Label2.Text = sLong2 + ", " + sLat2;
elong1 = Convert.ToDouble(sLong1);
elat1 = Convert.ToDouble(sLat1);
elong2 = Convert.ToDouble(sLong2);
elat2 = Convert.ToDouble(sLat2);
}
else {
Label1.Text = "Input Valid values";
}
and i want to get all the elong1 elat1 elong2 elat2 values to out side
double distLong = elong1 * (Math.PI / 180.0);
double distlat = elat1 * (Math.PI / 180.0);
double distLong1 = elong2 * (Math.PI / 180.0);
double distlat1 = elat2 * (Math.PI / 180.0);
i declared this aftr my if condition
but this it sho0ws me error that elong1 elat1 elong2 elat2 values are null?
so how i'm do that.........
promod madushan
10-Jul-13 10:44am
View
Please some one tell me how to view those images at once?
promod madushan
7-Jul-13 14:12pm
View
@Zafar...
how about i coded this in another hanler or somthing.... then called it from javascript....
promod madushan
7-Jul-13 4:36am
View
@Zafar... That's okay. i did that. but it gives same error.
zafar, in my code i have two sql queries. so is it okay if i put both queries inside the
protected void GridView1_RowDataBound(object sender,GridViewRowEventArgs e).
please mate reply me.
promod madushan
7-Jul-13 1:56am
View
it gives lots of errors @Zafar....
Error - Type 'System.Web.UI.WebControls.GridView' does not have a public property named 'TemplateField'.
Type 'System.Web.UI.WebControls.GridView' does not have a public property named 'ItemTemplate'.
i'm using visual studio 2012. that will be a problem yeah?
promod madushan
7-Jul-13 1:49am
View
@Zafar Safi
do i need to remove my c# code for button click event.....?
then i need to code for GridView1_RowDataBound yeah?
promod madushan
7-Jul-13 1:44am
View
i'll try!!!! thank you anyway......
promod madushan
6-Jul-13 3:52am
View
while (sqldread.Read())
{
int Dbid = (int)sqldread["Id"];
ArrayList al = new ArrayList();
Label4.Text = Convert.ToString(Dbid);
if (Dbid != null)
{
sqldread.Dispose();
String QueryStr = "SELECT Image FROM User_Images WHERE Id='" + Dbid + "'";
scmd1 = new SqlCommand(QueryStr, con);
scmd1.CommandType = CommandType.Text;
scmd1.Connection = con;
sqldread2 = scmd1.ExecuteReader();
while (sqldread2.Read())
{
Context.Response.BinaryWrite((byte[])sqldread2["Image"]);
Context.Response.ContentType = "image/jpg";
al.Add(sqldread2);
sDatAdp.SelectCommand = scmd1;
ListView1.DataSource = sqldread2;
ListView1.DataBind();
}
}
}
how about this?
is it right or wrong?
@Nirav
is that okay i 'll add your bindlist function to my code?
its like
protected void BindDataList()
{
DirectoryInfo dir = new DirectoryInfo(MapPath(QueryStr));// according to my code
FileInfo[] files = dir.GetFiles();
ArrayList listItems = new ArrayList();
foreach (FileInfo info in files)
{
listItems.Add(info);
}
dtlist.DataSource = listItems;
dtlist.DataBind();
promod madushan
6-Jul-13 0:49am
View
@Zafar Safi
how i view serveral images at once for above scenario?
promod madushan
5-Jul-13 21:34pm
View
There is already an open DataReader associated with this Command which must be closed first.
wht is this error in my code..
promod madushan
5-Jul-13 10:01am
View
while (sqldread.Read())
{
int Dbid = (int)sqldread["Id"];
String QueryStr = "INSERT INTO User_Images(Id,Image) VALUES ('" + Dbid + "',@Image)";
SqlCommand scmd1 = new SqlCommand(QueryStr, conn);
scmd1.ExecuteNonQuery();
}
now it's okay
and now it says
There is already an open DataReader associated with this Command which must be closed first.
promod madushan
5-Jul-13 9:51am
View
thanks, got it now.
promod madushan
5-Jul-13 9:47am
View
int Dbid = (int)sqldread["Id"];
i applied this method tooo
promod madushan
5-Jul-13 9:47am
View
both tables have id column with int data type....
and my first row
i have id=1, Source = abc
nw i input abc to textbox1 and i want to retrieve number 1 from that row
but it gives me "Invalid attempt to read when no data is present."
promod madushan
5-Jul-13 9:28am
View
Yeap.....
Same Error
Unable to cast object of type 'System.Data.DataColumn' to type 'System.IConvertible'.
promod madushan
5-Jul-13 9:24am
View
@ThePhantomUpvoter
i'm in rush , that's why i ask you an example?.. if you can please give me one.
promod madushan
5-Jul-13 9:22am
View
@ThePhantomUpvoter i tried manyways... but it's not worked?
if u can please tell me a propper way to do that
promod madushan
5-Jul-13 9:20am
View
now it's point to int Dbid and says...
Unable to cast object of type 'System.Data.DataColumn' to type 'System.IConvertible'.
promod madushan
5-Jul-13 9:12am
View
okay!!!
promod madushan
5-Jul-13 9:09am
View
nope... why is that?
promod madushan
5-Jul-13 9:01am
View
it's not working bro!!!!
promod madushan
5-Jul-13 8:45am
View
Invalid attempt to read when no data is present.
Same problem....
promod madushan
5-Jul-13 7:05am
View
Mate, Can you check this now....
i want to get database id value from first table and pass it to the second table.
so for that i need to pass the first database id value to integer variable, and i want to pass that value to second table's ID.
let' say in my first table my id value is 1.
so i want to pass that value to integer variable and
then i want to insert that integer value to second table.
so how can i do that?
how i can pass data base value to integer value
int MId = int.Parse(@Id);
is this correct or not?
promod madushan
5-Jul-13 7:01am
View
thanks to information!!!!
promod madushan
5-Jul-13 6:27am
View
tell me how i can solve this thing.
promod madushan
5-Jul-13 5:00am
View
ah okay... if you have something to refer please put it here?
promod madushan
5-Jul-13 4:28am
View
can't i do it with two data bases? like
first database for data and 2nd one for images....
like if your first table's data okay... then it goes to 2nd table to add the image.
when i retrieve those images i can use for loop to view that?
is that correct or not.
promod madushan
5-Jul-13 2:42am
View
anysize image
and cant i give page by page viewing ability like fb.....
or do u have any other methods to storing and retrieving images? without using db's?
promod madushan
5-Jul-13 2:05am
View
okay.... thanks
promod madushan
4-Jul-13 13:18pm
View
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=PROMOD-PC;Initial Catalog=travel_Directions;Integrated Security=True";
DataTable dt = new DataTable();
String selQuery = "SELECT Image FROM MapDataImage WHERE Source='" + TextBox1.Text + "';";
SqlCommand SelCmmnd = new SqlCommand(selQuery);
SqlDataAdapter sDatAdp = new SqlDataAdapter();
SelCmmnd.CommandType = CommandType.Text;
SelCmmnd.Connection = con;
con.Open();
sDatAdp.SelectCommand = SelCmmnd;
sDatAdp.Fill(dt);
ListView1.DataSource = dt;
ListView1.DataBind();
con.Close();
sDatAdp.Dispose();
con.Dispose();
dt.Dispose();
}
@Tadit how about this?
here i want to convert bytes to image via datareader or dataadapter
Please help me?
this will be a big help
promod madushan
4-Jul-13 12:52pm
View
error was reader is not in current context
promod madushan
4-Jul-13 12:51pm
View
hey i posted this one because to my previous one anyone didn't gave me a propper answer
promod madushan
4-Jul-13 10:18am
View
@Nirav
can't i use that kind of a code after sDatAdp.Fill(dt); this code...
can't i convert this dt into bytes and display it in ListView
promod madushan
4-Jul-13 10:16am
View
in my code?
cant i replace
byte[] photoarray = ((byte[])dt."@Image");
this like a code?
this code is made by me. but it's not working
promod madushan
4-Jul-13 10:02am
View
can't i add converting to bytes method in middle of the code...?
promod madushan
4-Jul-13 7:58am
View
Image: System.Byte[] guys now code is ready... but when i clicked the button... it will show label like Image: System.Byte[]....
is there any problem in the code?
promod madushan
4-Jul-13 7:49am
View
you mean do i have to remove client side DataSource or DataSourceID
promod madushan
4-Jul-13 6:03am
View
Error -
Both DataSource and DataSourceID are defined on 'ListView1'. Remove one definition.
promod madushan
4-Jul-13 5:50am
View
Thanks Mate!!!!
promod madushan
4-Jul-13 5:28am
View
String QueryStr = "UPDATE MapDataImage SET Image = @Image WHERE Source='" + TextBox1.Text + "';";
i'm using the same code.. and it's working.... so does it matter?
promod madushan
4-Jul-13 4:43am
View
Thanks mate , Its Working
promod madushan
4-Jul-13 4:40am
View
String QueryStr = "UPDATE MapDataImage SET Image = @Image WHERE Source='" + TextBox1.Text + "';";
now is it okay?
promod madushan
4-Jul-13 4:28am
View
Thanks mate!!!!
promod madushan
4-Jul-13 4:25am
View
I think then i need a update query... yeah?
promod madushan
4-Jul-13 4:22am
View
i have values on database...
my sql database consist..
Source Varchar(max)
Age int
Image Varbinary(max)
so there, i store values manually
eg = name john , age 20
i want to check weather user input john or not to the textbox...
if textbox value equals to john ... then only i can add images to Image Field..
// i need to compare the values between textbox and database.
.....
Think example as Facebook... i can only add my pics if i'm login with my account only know.
so kind of that...
promod madushan
4-Jul-13 4:11am
View
String QueryStr = "INSERT INTO MapDataImage VALUES @Image WHERE @Source='" + TextBox1.Text + "';";
now is it okay?
promod madushan
4-Jul-13 4:07am
View
thanks for the comment mate....
but i want to check if textbox value match with particular field and then only i can add image to the image field.
eg - if my name is promod and if sql database hold myname only i can upload my photo.
that's my logic...
if i'm wrong correct me....
thanks mate!!!!
promod madushan
4-Jul-13 4:01am
View
guys it points to
scmd.ExecuteNonQuery(); and says
Incorrect syntax near 'Image'.
promod madushan
4-Jul-13 3:59am
View
thanks mate!!!
promod madushan
4-Jul-13 3:14am
View
Thanks mate!!!!
promod madushan
4-Jul-13 1:56am
View
DbPath.CommandText = "INSERT INTO MapDataImage VALUES Image WHERE @Source='" + TextBox1.Text + "';";
is this okay?
promod madushan
4-Jul-13 1:54am
View
hey , it gives an error and it says represent text as series of unicode characters
promod madushan
3-Jul-13 0:20am
View
dont u feel i'm new to the field?
promod madushan
2-Jul-13 22:27pm
View
taht's correct!!!!!
promod madushan
2-Jul-13 10:04am
View
thanks for your thoughts.......
promod madushan
2-Jul-13 8:26am
View
thank you bro!!!!
promod madushan
1-Jul-13 9:12am
View
i think you can't understand my question properly ri8? so do i need to explain more?
promod madushan
1-Jul-13 9:08am
View
Thanks....
promod madushan
1-Jul-13 6:15am
View
@ThePhantomUpvoter
don't care about api things geocode,etc.
i have done that and its working...
i just publish variables which i want to access in another class and if this wrong i just want a propper way to access this variables in another class.
promod madushan
1-Jul-13 5:56am
View
if i can do it myself i don't ask for help my friend!!!!!
promod madushan
1-Jul-13 5:45am
View
@manu v nath
i want to pass Fanswer to button click event know.
so
the answer gonna be
TryParse(Fanswer);
then i can pass the value of Fanswer to label or textbox easily in button click event.
Right
Label1.Text = Fanswer;
is this okay
promod madushan
1-Jul-13 5:43am
View
@Rajesh
i want to pass Fanswer to button click event know.
so
the answer gonna be
Double.TryParse(Fanswer);
right.
So is this correct.
promod madushan
1-Jul-13 5:14am
View
okay
promod madushan
1-Jul-13 3:43am
View
this method is correct know?
promod madushan
1-Jul-13 2:31am
View
can you check this again? because i improved my question...
actually i dont have a problem with geocode part, because it's working.
but i want to access those slat1, slong1, slat2, slong2 values in another class....
i accept that my code might not well. because i'm new to the field.
so please as a help, check it again.... big help
promod madushan
1-Jul-13 0:03am
View
public class harversine {
String valueEnd_Address = Login.End_Address;
}
Ron is this correct?...........
promod madushan
1-Jul-13 0:02am
View
still not working bro!!!!
it says "Login.TextBox2 is a field" but is use like a type....
promod madushan
30-Jun-13 23:54pm
View
in my question access value in the class not working still
i think its should be like this?
public class harversine {
//Login instance = new Login();
String valueEnd_Address = Login.End_Address;
am i correct................
so using this i can get value of that textbox using that End_Address string? am i correct?
promod madushan
30-Jun-13 23:46pm
View
so then i can now access my End_Address value within the class
promod madushan
30-Jun-13 23:25pm
View
okay okay!!!
but i just want List<directionsteps>.... this expanation only......
promod madushan
30-Jun-13 3:07am
View
Deleted
@sampth here my current code... i created this code for get longitude and latitude.... and aftr i get latlng.... i'm passing it to the label...
so now i want to pass latlong or two positions to the direction api as well to get direction
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
//using System.Web.UI.Page;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.IO;
using System.Xml;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Page.ClientScript.RegisterStartupScript(Page.GetType(), "script",
//"calcRoute()", true);
//String var1;
//this.Button1.Attributes.Add("onClick", "calcRoute()");
//ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "calcRoute();", true);
}
public void Button1_Click(object sender, EventArgs e)
{
String Strt_Address = TextBox1.Text;
String End_Address = TextBox2.Text;
//var element = Request["TextBox1"];
//var element2 = Request["TextBox2"];
string geocodeUrl1 = string.Format(@"http://maps.googleapis.com/maps/api/geocode/xml?address={0}&sensor=false", Strt_Address);
string geocodeUrl2 = string.Format(@"http://maps.googleapis.com/maps/api/geocode/xml?address={0}&sensor=false", End_Address);
XmlDocument geocodeXmlDoc1 = new XmlDocument();
geocodeXmlDoc1.Load(geocodeUrl1);
XmlDocument geocodeXmlDoc2 = new XmlDocument();
geocodeXmlDoc2.Load(geocodeUrl2);
//XmlDocument geoDirectXmlDoc = new XmlDocument();
//geoDirectXmlDoc.Load(geoDirect1);
XmlNamespaceManager XmlMngr1 = new XmlNamespaceManager(geocodeXmlDoc1.NameTable);
XmlMngr1.AddNamespace("geo", @"http://www.w3.org/2003/01/geo/wgs84_pos#");
XmlNamespaceManager XmlMngr2 = new XmlNamespaceManager(geocodeXmlDoc2.NameTable);
XmlMngr2.AddNamespace("geo", @"http://www.w3.org/2003/01/geo/wgs84_pos#");
// Code for directions
// longitude and latitude set
string sLong1 = geocodeXmlDoc1.DocumentElement.SelectSingleNode(@"//geometry/location/lat", XmlMngr1).InnerText;
string sLat1 = geocodeXmlDoc1.DocumentElement.SelectSingleNode(@"//geometry/location/lng", XmlMngr1).InnerText;
string sLong2 = geocodeXmlDoc2.DocumentElement.SelectSingleNode(@"//geometry/location/lat", XmlMngr2).InnerText;
string sLat2 = geocodeXmlDoc2.DocumentElement.SelectSingleNode(@"//geometry/location/lng", XmlMngr2).InnerText;
Label1.Text = sLong1 + ", " + sLat1;
Label2.Text = sLong2 + ", " + sLat2;
//Label1.Text ="6.927079, 79.861243";
//Label2.Text = "6.890770, 79.871684";
//ScriptManager.RegisterStartupScript(this, this.GetType(), "onSubmit", "calcRoute();", true);
//Page.ClientScript.RegisterClientScriptBlock(typeof(ScriptManager), "CallMyMethod", "calcRoute();");
//print.Attributes.Add("onclick", "calcRoute();");
//ScriptManager.RegisterStartupScript(Page, GetType(), "JsStatus", "calcRoute();", true);
//ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "calcRoute();", true);
//ScriptManager.RegisterStartupScript(var1, var1.GetType(), "starScript", "calcRoute();", true);
//Label3.Text = "<script type='text/javascript'>showDialogue();</script>";
Page.ClientScript.RegisterStartupScript(Page.GetType(), "script",
"calcRoute()", true);
}
}
promod madushan
30-Jun-13 3:04am
View
Deleted
my question code ..... i created it manually
i'm bit mixed up with this code...........
thats why?
promod madushan
30-Jun-13 3:03am
View
Deleted
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
public class GMapUtil
{
public static List GetDirections(string origin, string destination)
{
var requestUrl = string.Format("http://maps.google.com/maps/api/directions/xml?origin={0}&destination={1}&sensor=false", origin, destination);
try
{
var client = new WebClient();
var result = client.DownloadString(requestUrl);
return ParseDirectionResults(result);
}
catch (Exception)
{
return null;
}
}
private static List ParseDirectionResults(string result)
{
var directionStepsList = new List();
var xmlDoc = new XmlDocument {InnerXml = result};
if (xmlDoc.HasChildNodes)
{
var directionsResponseNode = xmlDoc.SelectSingleNode("DirectionsResponse");
if (directionsResponseNode != null)
{
var statusNode = directionsResponseNode.SelectSingleNode("status");
if (statusNode != null && statusNode.InnerText.Equals("OK"))
{
var legs = directionsResponseNode.SelectNodes("route/leg");
foreach (XmlNode leg in legs)
{
int stepCount = 1;
var stepNodes = leg.SelectNodes("step");
var steps = new List();
foreach (XmlNode stepNode in stepNodes)
{
var directionStep = new DirectionStep();
directionStep.Index = stepCount++;
directionStep.Distance = stepNode.SelectSingleNode("distance/text").InnerText;
directionStep.Duration = stepNode.SelectSingleNode("duration/text").InnerText;
directionStep.Description = Regex.Replace(stepNode.SelectSingleNode("html_instructions").InnerText, "<[^<]+?>", "");
steps.Add(directionStep);
}
var directionSteps = new DirectionSteps();
Label1.Text = leg.SelectSingleNode("start_address").InnerText;
directionSteps.DestinationAddress = leg.SelectSingleNode("end_address").InnerText;
directionSteps.TotalDistance = leg.SelectSingleNode("distance/text").InnerText;
directionSteps.TotalDuration = leg.SelectSingleNode("duration/text").InnerText;
directionSteps.Steps = steps;
directionStepsList.Add(directionSteps);
}
}
}
}
return directionStepsList;
}
}
public class DirectionStep
{
public int Index { get; set; }
public string Description { get; set; }
public string Distance { get; set; }
public string Duration { get; set; }
}
public class DirectionSteps
{
public string TotalDuration { get; set; }
public string TotalDistance { get; set; }
public string OriginAddress { get; set; }
public string DestinationAddress { get; set; }
public List Steps { get; set; }
}
}
}
plsss some one tell me whats happen in here exactly........
currently i have found a way to gt lat and long...
but i want now is from lat lang i want to get direction and add those direction step into text area...
so for that... how can i change this code according to it.... and tell me how to do that....
pls pls pls
promod madushan
29-Jun-13 7:44am
View
means i want it c# side not javascript side?
promod madushan
29-Jun-13 6:25am
View
please i want it from c#......... i want some c# code for find directions...
plsssssssssssssssssssssssss
this is also good... but really want this in c#
promod madushan
26-Jun-13 2:10am
View
please tell me a solution for this? big help........
i have a c# code as well...
that part will get the address wcich user input to texbox and convert to longitude and latitude.
and pass it to the labels
Show More