Click here to Skip to main content
16,015,481 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hey Guys,

This is my asp code:

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

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!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>
    <style type="text/css">
        .style2
        {
            width: 1147px;
            height: 109px;
        }
        .style3
        {
            width: 276px;
        }
        #control
        {
            height: 249px;
        }
        .style4
        {
            width: 426px;
        }
        .style5
        {
            width: 276px;
            height: 83px;
        }
        .style6
        {
            width: 426px;
            height: 83px;
        }
        .style7
        {
            height: 83px;
        }
    </style>
</head>

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script language="javascript" type="text/javascript">
    var directionsDisplay;
    var directionsService = new google.maps.DirectionsService();
    var unitSystem;
    var vehicle;

    function InitializeMap() {
        directionsDisplay = new google.maps.DirectionsRenderer();
        var latlng = new google.maps.LatLng(19.082063,72.888215);
        var myOptions =
        {
            zoom: 17,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

        directionsDisplay.setMap(map);

        directionsDisplay.setPanel(document.getElementById('directions_panel'));

     //   string xxxx = directionsDisplay.toString();
    //    prompt(xxxx);


        var control = document.getElementById('control');
        control.style.display = 'block';


    }



    function calcRoute() {

        var start = document.getElementById('DropDownList1').value;
        var end = document.getElementById('DropDownList2').value;
        var request = {
            origin: start,
            destination: end,
            provideRouteAlternatives: true,
            unitSystem: google.maps.UnitSystem.METRIC,
            travelMode: google.maps.DirectionsTravelMode.DRIVING,
            avoidHighways: document.getElementById('highways').checked,
            avoidTolls: document.getElementById('tolls').checked


        };
        directionsService.route(request, function (response, status) {
            if (status == google.maps.DirectionsStatus.OK) {
                directionsDisplay.setDirections(response);
            }
                    });

}

    function Button1_onclick() {
        calcRoute();
    }

    window.onload = InitializeMap;
    </script>

<body class="body1">
    <form id="form1" runat="server">

    <table id ="control">
<tr>
<td class="style2">
                &nbsp;<br />
                <table style="width:100%;">
                    <tr>
                        <td class="style3">
                            SOURCE:</td>
                        <td class="style4">
                            <asp:DropDownList ID="DropDownList1" runat="server"
                                DataSourceID="SqlDataSource1" DataTextField="Source" DataValueField="Source">
                            </asp:DropDownList>
                            <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                                ConnectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\getDir.mdf;Integrated Security=True;User Instance=True"
                                ProviderName="System.Data.SqlClient"
                                SelectCommand="SELECT DISTINCT [Source] FROM [path]"></asp:SqlDataSource>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style5">
                            <input type="checkbox" id="highways" />Avoid highways</td>
                        <td class="style6">
                            <input type="checkbox" id="tolls" />Avoid tolls</td>
                        <td class="style7">
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style3">
                            DESTINATION:</td>
                        <td class="style4">
                            <asp:DropDownList ID="DropDownList2" runat="server"
                                DataSourceID="SqlDataSource2" DataTextField="Destination"
                                DataValueField="Destination">
                            </asp:DropDownList>
                            <asp:SqlDataSource ID="SqlDataSource2" runat="server"
                                ConnectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\getDir.mdf;Integrated Security=True;User Instance=True"
                                ProviderName="System.Data.SqlClient"
                                SelectCommand="SELECT DISTINCT [Destination] FROM [path]">
                            </asp:SqlDataSource>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                </table>
                <br />
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:Button ID="Button2" runat="server" onclick="Button2_Click" onclientclick="calcRoute(); return false;" Text="GET DIRECTION" Height="24px"
                    Width="222px"/>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:Button ID="Button3" runat="server" Text="RESET" onclick="Button3_Click"
                    style="width: 81px" />
                <br />
                <br />
                </td>
</tr>
</table>
<div id="map_canvas" style="float:left;width:64%; height:609px"></div>
<div style="float:none; width:35%; height:610px; overflow:auto">
  <div id="directions_panel" style="width:140%; height: 852px;"></div>
</div>


 <div style="width: 415px">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:LinkButton ID="LinkButton1" runat="server" Font-Bold="True"
            Font-Size="Medium">ESTIMATED FUEL COST</asp:LinkButton>
        <cc1:ModalPopupExtender ID="ModalPopupExtender1" BackgroundCssClass="ModalPopupBG"
            runat="server" CancelControlID="Button4" OkControlID="Button1" TargetControlID="LinkButton1"
            PopupControlID="Panel1" Drag="true" PopupDragHandleControlID="PopupHeader">
        </cc1:ModalPopupExtender>
        <asp:Panel ID="Panel1" runat="server" Height="295px" Width="687px" style="display: none;">
            <div class="popup_Container">
                <div class="popup_Titlebar" id="PopupHeader">
                    <div class="TitlebarLeft">
                        Fuel Estimation</div>
                    <div class="TitlebarRight">
                    </div>
                </div>
                <div class="popup_Body">
                    <br />
            &nbsp;&nbsp;&nbsp;
                    <asp:Label ID="Label1" runat="server" Text="Vehicle Type:"></asp:Label>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="True">
                        <asp:ListItem>Select</asp:ListItem>
                        <asp:ListItem>Petrol</asp:ListItem>
                        <asp:ListItem>Diesel</asp:ListItem>
                    </asp:DropDownList>
                    <br />
                    <br />
            &nbsp;&nbsp;&nbsp;
                    <asp:Label ID="Label2" runat="server" Text="Cost/Litre:"></asp:Label>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <br />
                    <br />
            &nbsp;&nbsp;&nbsp;
                    <asp:Label ID="Label3" runat="server" Text="Distance needed to travel: "></asp:Label>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Label ID="Label4" runat="server" Text="(Km)"></asp:Label>
                    <br />
                    <br />
            &nbsp;&nbsp;&nbsp;
                    <asp:Label ID="Label5" runat="server" Text="Average:"></asp:Label>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Label ID="Label6" runat="server" Text="(Km/l)"></asp:Label>
                    <br />
                    <br />
            &nbsp;&nbsp;&nbsp;
                    <asp:Label ID="Label7" runat="server" Text="Fuel Required:"></asp:Label>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="TextBox4" runat="server" Enabled="False"></asp:TextBox>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Label ID="Label8" runat="server" Text="(Litre)"></asp:Label>
                    <br />
                    <br />
            &nbsp;&nbsp;&nbsp;
                    <asp:Label ID="Label9" runat="server" Text="Cost Incurred:"></asp:Label>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="TextBox5" runat="server" Enabled="False"></asp:TextBox>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Label ID="Label10" runat="server" Text="(Rupees)"></asp:Label>
                    <br />
                    <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                </div>
                <div class="popup_Buttons">
                    <asp:Button ID="Button1" runat="server" Text="Submit" />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="Button4" runat="server" Text="Cancel" />
                </div>
                <br />
                <br />
                <br />
                <br />
            </div>
        </asp:Panel>



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



Whenever I try to use the textboxes mentioned in the <asp:panel> in the codebehind part (apsx.cs) page I get an error saying "The name 'TextBox' does not exist in the current context".
Please suggest a solution for this problem.

Thanks in advance.
Posted
Comments
[no name] 31-Mar-13 16:52pm    
I don't see anywhere where you have a control named "TextBox". I see TextBox1, TextBox2, etc but no TextBox.
Sergey Alexandrovich Kryukov 31-Mar-13 21:11pm    
Good point. :-)
—SA

1 solution

Please see the comment by ThePhantomUpvoter. That said, your code sample is totally inadequate to the question.

Now, as this is ASP.NET, and the name TextBox is involved, all you need it too look at the MSDN help page:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.aspx[^].

It tells you that the exact type of TextBox in ASP.NET is actually System.Web.UI.WebControls.TextBox; also, it tells you that it requires to reference the assembly "System.Web.dll".

I hope you know how to reference assemblies of GAC and work with namespaces. If not, learn it before doing any programming at all.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900