Ok. So I have a simple website with a username and password textbox along with a submit button in vb2008 which is supposed to lead to a new page which accesses a SQL source table in grid view. I am supposed to enter "mcobery" as the username and "password" as the password, when I do that, nothing happens. Is there something wrong with my code behind?
Take a look at my code behind along with my default page and the page it leads to code.
This is the code behind
Protected Sub butSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles butSubmit.Click
Dim correctPassword As Boolean = False
'Establish the SqlConnection by using the configuration manager to get the connection string in our web.config file.
Using mySqlConnection = New Data.SqlClient.SqlConnection (ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
Dim sql As String = "SELECT password FROM MyUsers WHERE username = #userName"
Using mySqlCommand = New Data.SqlClient.SqlCommand(sql, mySqlConnection)
mySqlCommand.Parameters.AddWithValue("#userName", Me.TextBox1.Text)
Try
mySqlConnection.Open()
Using myReader = mySqlCommand.ExecuteReader()
If myReader.Read() Then
Dim password As String = myReader.GetString(myReader.GetOrdinal("password"))
If password = Me.TextBox2.Text Then
'Open page with users and roles
correctPassword = True
End If
End If
End Using
Catch ex As Exception
Console.WriteLine(ex.ToString())
End Try
End Using
End Using
If correctPassword Then
Response.Redirect("userAdmin.aspx")
End If
End Sub
End Class
My default.aspx page
<%# Page Language="VB" Debug="true" MasterPageFile="~/master.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="header" Runat="Server">
<p style="text-align: center; color: white">
SAM PEPPARD</p>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="navigation" Runat="Server">
Default.aspx
<br />
<br />
userAdmin.aspx
<br />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="main" Runat="Server">
    User Name
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    Password <asp:TextBox ID="TextBox2"
runat="server" TextMode="Password"></asp:TextBox>
   
<asp:Button ID="butSubmit" runat="server" Text="Submit" />
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="footer" Runat="Server">
</asp:Content>
The page it is supposed to lead to when you press submit. It is called userAdmin.aspx
<%# Page Language="VB" MasterPageFile="~/master.master" AutoEventWireup="false" title="UserAdmin" %>
<asp:Content ID="Content1" ContentPlaceHolderID="header" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="navigation" Runat="Server">
Default.aspx
<br />
<br />
userAdmin.aspx
<br />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="main" Runat="Server">
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [MyUsers]"></asp:SqlDataSource>
<asp:GridView ID="UserRolesGrid" runat="server" DataSourceID="SqlDataSource1"
Width="399px" AutoGenerateColumns="False" DataKeyNames="id">
<Columns>
<asp:BoundField DataField="id" HeaderText="id" InsertVisible="False"
ReadOnly="True" SortExpression="id" />
<asp:BoundField DataField="user_logon_id" HeaderText="user_logon_id"
SortExpression="user_logon_id" />
<asp:BoundField DataField="user_full_name" HeaderText="user_full_name"
SortExpression="user_full_name" />
<asp:BoundField DataField="user_description" HeaderText="user_description"
SortExpression="user_description" />
<asp:BoundField DataField="user_password" HeaderText="user_password"
SortExpression="user_password" />
</Columns>
</asp:GridView>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="footer" Runat="Server">
</asp:Content>
here is the master page code if that helps
<%# Master Language="VB" CodeFile="master.master.vb" Inherits="master" %>
<!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>
<title>Website 1</title>
<style type="text/css">
.fullHW
{
width: 100%;
height: 100%;
}
.fullW
{
width: 100%;
}
.header
{
color:black;
background-color:indigo;
height: 100px;
font-size:16.0pt;
font-family:"Arial","sans-serif";
}
.footer
{
color:white;
background-color:indigo;
height: 100px;
font-size:8.0pt;
font-family:"Arial","sans-serif";
}
.nav
{
background-color:black;
width: 200px;
height: 400px;
font-size:11.0pt;
color:black;
font-family:"Arial","sans-serif";
}
.content
{
background-color:white;
height: 100%;
font-size:11.0pt;
color:black;
font-family:"Arial","sans-serif";
}
a:link { color:white; text-decoration:none; }
a:visited { color:white; text-decoration:none; }
a:hover { color:white; text-decoration:none; }
a:active { color:white; text-decoration:none; }
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="fullHW">
<table border="0" cellpadding="0" cellspacing="0" class="fullHW">
<tr class="fullHW">
<td class="header">
<asp:ContentPlaceHolder ID="header" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
<tr class="fullHW">
<td>
<table border="0" cellpadding="0" cellspacing="0" class="fullHW">
<tr class="fullHW">
<td class="nav">
<asp:ContentPlaceHolder ID="navigation" runat="server">
Default.aspx
<br />
<br />
userAdmin.aspx
</asp:ContentPlaceHolder>
</td>
<td class="content">
<asp:ContentPlaceHolder ID="main" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
</td>
</tr>
<tr class="fullHW">
<td class="footer">
<asp:ContentPlaceHolder ID="footer" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
I do not see you associating the btnSubmit_Click method with the btnSubmit button.
I guess you can handle the submit click button in the Page_Load handler after checking for IsPostBack.
Related
How to show an image in ContentPlaceHolder4 on click of a Link Button which is placed on ContentPlaceHolder3.
I Have a Master Page and one content page. On master page i have a link INSTRUMENTS by clicking on which i am redirected to content page INSTRUMENTS. Now i have 10 LINK BUTTON controls on my Content Page and i want on the click of each link button corresponding image should open on same content page but in different CntentPlaceHolder. Please guide me how to add code for Link Button Click and how to render iamge on click of Link Button.
Following is the code i have added till now.
**This is My Master Page**
<%# Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!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></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<style type="text/css">
.style1
{
}
.style2
{
width: 162px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div> <img src="IMAGES/main.png" style="background-color: #99FF99; border-top-color: #800000; width: 1082px; height: 105px;" />
</div>
HOME INSTRUMENTS LOGIN
ADDRESS
<table style="width: 100%; height: 288px; margin-top: 11px;">
<tr>
<td bgcolor="#FF0066" align="center" class="style2"
style="text-align: center; vertical-align: top;">
<asp:ContentPlaceHolder ID="ContentPlaceHolder3" runat="server">
</asp:ContentPlaceHolder>
</td>
<td bgcolor="#33CCCC" class="style1">
<asp:ContentPlaceHolder ID="ContentPlaceHolder4" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
</form>
</body>
</html>
**This is My Content Page**
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="INSTRUMENTS.aspx.cs" Inherits="INSTRUMENTS" %>
<asp:Content id="content3" ContentPlaceHolderID="head" runat="server">
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server">
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="lkbutton_click">Sitar</asp:LinkButton><br />
<asp:LinkButton ID="LinkButton2" runat="server">Harmonium</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton3" runat="server">Tabla</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton4" runat="server">Drum</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton5" runat="server">Guitar</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton6" runat="server">Sarod</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton7" runat="server">Flute</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton8" runat="server">Santoor</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton9" runat="server" onclick="LinkButton9_Click">Keyboard</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton10" runat="server">LinkButton</asp:LinkButton>
</asp:Content>
<asp:content ID ="C2" ContentPlaceHolderID ="ContentPlaceHolder4" runat="Server">
<asp:Image ID ="I1" ImageUrl ="~/IMAGES/F.png" >
<asp:Image />
</asp:content>
in your design page use like this.
<asp:Content ContentPlaceHolderID="ContentPlaceHolder4" Runat="Server">
<img id="img1" runat="server" />
</asp:Content>
and in code behind link button click event like below:
protected void lkbutton_click(object sender, EventArgs e)
{
img1.Src = "~/images/sonata-logo.png";
}
i tested it it's working fine.
but put the correct path of image then only it will show.
Thanks
<asp:LinkButton ID="LinkButton1" runat="server" width="250px" height="250">
<img runat="server" id="IL"src="~/Class/Adds/0/4.jpg" width="250" height="250" />
</asp:LinkButton>
With this you can change the picture with server code.
il.SRC = "~/Class/Adds/0/7.jpg"
i have page and add Ajax extension but it throwing error for me
i am using master page so this page doesn't have <head>
page code
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%# Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" runat="server" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table style="width: 100%">
<tr>
<td colspan="5" style="text-align: center; height: 20px;">Search </td>
</tr>
<tr>
<td style="text-align: center; height: 20px;">Ticket number</td>
<td style="text-align: center; height: 20px;">Client name</td>
<td style="text-align: center; height: 20px;">Address</td>
<td style="text-align: center; height: 20px;">Assigned to</td>
<td style="text-align: center; height: 20px;">Date</td>
</tr>
<tr>
<td style="width: 157px">
<asp:TextBox ID="txt_incID" runat="server" Width="146px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="txb_ClientName" runat="server" Width="146px"></asp:TextBox>
</td>
<td>
<asp:DropDownList ID="ddl_Address" runat="server" Width="146px" DataSourceID="Ds_address" DataTextField="StrName" DataValueField="StrID">
<asp:ListItem Value="null"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="ddl_EmpID" runat="server" Width="146px" DataSourceID="DS_Employee" DataTextField="LastName" DataValueField="EmpID">
<asp:ListItem Value="null"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="txb_date" runat="server" Width="146px"></asp:TextBox>
<asp:CalendarExtender ID="txb_date_CalendarExtender" runat="server" Enabled="True" TargetControlID="txb_date">
</asp:CalendarExtender>
</td>
</tr>
<tr>
<td style="width: 157px"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td style="width: 157px"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<br />
<br />
<asp:SqlDataSource ID="Ds_address" runat="server" ConnectionString="<%$ ConnectionStrings:TicketsConnectionString %>" SelectCommand="SELECT * FROM [Streets]"></asp:SqlDataSource>
<asp:SqlDataSource ID="DS_Employee" runat="server" ConnectionString="<%$ ConnectionStrings:TicketsConnectionString %>" SelectCommand="SELECT * FROM [Employee]"></asp:SqlDataSource>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</asp:Content>
in other topics people recommend add this
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
but I have it on my page. Any ideas how to fix?
Master page code
<%# Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Tickets</title>
<link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700|Archivo+Narrow:400,700" rel="stylesheet" type="text/css">
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<style type="text/css">
.Buttons
{
font-family: Tahoma;
font-size: large;
background-color: #999999;
border-bottom-color: #FF0000;
border-style: none none outset none;
}
.Logins
{
font-family: tahoma;
color: #FF0000;
}
.ButtonsInSite
{
font-family: tahoma;
background-color: #C0C0C0;
border-color: #FFFFFF #FFFFFF #FF0000 #FFFFFF;
border-bottom-style: double;
border-radius: 7px;
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
box-shadow: 0px 2px 9px #800000;
font-weight: bold;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="header-wrapper">
<div id="header">
<div id="logo">
<h1>Tickets</h1>
<div style="text-align: right">
<asp:LoginName ID="LoginName2" runat="server" CssClass="Logins" />
|
<asp:LoginStatus ID="LoginStatus1" runat="server" CssClass="Logins" />
</div>
</div>
</div>
</div>
<div id="wrapper">
<!-- end #header -->
<div id="page">
<div id="page-bgtop">
<div id="page-bgbtm">
<div id="sidebar">
<h2>Navigation</h2>
<asp:Button ID="Button1" runat="server" Text="Button" Width="118px" CssClass="ButtonsInSite" />
<br />
<asp:Button ID="Button2" runat="server" Text="Button" Width="118px" CssClass="ButtonsInSite"/>
<br />
<asp:Button ID="Button3" runat="server" Text="Button" Width="118px" CssClass="ButtonsInSite"/>
<br />
<asp:Button ID="Button4" runat="server" Text="Button" Width="118px" CssClass="ButtonsInSite"/>
<br />
<asp:Button ID="Button5" runat="server" Text="Admin" Width="118px" CssClass="ButtonsInSite" PostBackUrl="~/Admin/AdmStart.aspx"/>
<br />
</div>
<!-- end #sidebar -->
<div id="content">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<!-- end #content -->
<div style="clear: both;"> </div>
</div>
</div>
</div>
<!-- end #page -->
</div>
<div id="footer">
<p> © 2013</p>
</div>
<!-- end #footer -->
</form>
</body>
</html>
May be this will help you.
Master page Html
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
Child Page Html
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">Add Scripts here</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
Add Page Content Here</asp:Content>
Add in the master page
<head runat="server">
In a child page header ContentPlaceHolderID just add <head runat="server"></head>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2Header" runat="Server">
<head runat="server">
</head>
<script src="http://code.jquery.com/jquery-latest.min.js"
type="text/javascript"></script>
</asp:Content>
Can you add <head runat="server"> to the master page??
In Master Page add
<head id="Head1" runat="server">
//Other script
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
In child page add
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
//add script for child page
<script>
</script>
</asp:Content>
Try this
<%# Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
in the MASTER PAGE code!
Just substitute <head> for <head id="head1" runat="server">
I am working on an Asp .net project and i Am using RadSplitter to split me website. I want to remove the borders from the splitter. Here is my asp code below, i remove the borders but they are still appear. Can anyone help me please?
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="webbetv1.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%# Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<html runat="server">
<head >
<style type="text/css">
.RadSplitter .pane,
.RadSplitter .paneHorizontal
{
border: 0px !important;
padding: 0px !important;
}
.style1
{
width: 100%;
margin-bottom: 33px;
}
</style>
<script type="text/javascript">
//Put your JavaScript code here.
</script>
</head>
<form id="Form1" runat="server">
<body>
<telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
</telerik:RadScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
</telerik:RadAjaxManager>
<div style="height:800px; width: auto;">
<telerik:RadSplitter ID="MainSplitter" runat="server" Width="100%" Height="100%" ExpandMode="FullExpandItem"
Orientation="Horizontal" LiveResize="false" BorderSize="0" BorderWidth="0px" BorderStyle="None" CssClass="pane" >
<telerik:RadPane ID="TopPane" runat="server" Height="120" MinHeight="85" MaxHeight="150" BorderWidth="0px"
Scrolling="none" CssClass="pane" >
<asp:PlaceHolder ID="PlaceHolder3" runat="server"></asp:PlaceHolder>
<table class="style1">
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
sadasd</td>
<td>
</td>
</tr>
</table>
</telerik:RadPane>
<telerik:RadSplitBar ID="RadsplitbarTop" runat="server" CollapseMode="Forward" Height="100%" BorderWidth="0px" BorderStyle="None" />
</telerik:RadSplitter>
</div>
</body>
</form>
</html>
Try adding
border: none;
to your .pane css class.
I had the same problem and I had to add that to the css class as well as setting BorderStyle="None" and BorderSize="0" . I'm working with a master page and I suspected that the property was being overwritten somewhere.
No css should be necessary in order to remove the borders:
On the RadSplitter set:
PanesBorderSize="0" BorderWidth="0"
On the RadPane set:
BorderWidth="0"
Now that the image is visible, maybe you just want to hidden the RadSplitBar. In that case you can both remove it or just set Visible="False".
When I use this code in my master page, it can’t be debugged. But before this, which I didn't use master page, it perfectly worked. Is there something wrong with my code? I put my code here for your reference. Appreciate very much.
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="User.aspx.cs" Inherits="Admin_User" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder4" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder5" Runat="Server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="User.aspx.cs" Inherits="Admin_User" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder4" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder5" Runat="Server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<p>
This is a list of user in a database.</p>
<p><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Edit,update and delete User accounts in asp.net membership</title>
<style type="text/css">
.GridviewDiv {font-size: 100%; font-family: 'Lucida Grande', 'Lucida Sans Unicode',
Verdana, Arial, Helevetica, sans-serif; color: #303933;}
Table.Gridview{border:solid 1px #df5015;}
.Gridview th{color:#FFFFFF;border-right-color:#abb079;border-bottom-
color:#abb079;padding:0.5em 0.5em 0.5em 0.5em;text-align:center}
.Gridview td{border-bottom-color:#f0f2da;border-right-color:#f0f2da;padding:0.5em 0.5em
0.5em 0.5em;}
.Gridview tr{color: Black; background-color: White; text-align:left}
:link,:visited { color: #DF4F13; text-decoration:none }
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="GridviewDiv">
<asp:GridView ID="gvDetails" runat="server" CssClass="Gridview"
AutoGenerateColumns="false"
AutoGenerateDeleteButton="true" AutoGenerateEditButton="true"
onrowcancelingedit="gvDetails_RowCancelingEdit"
onrowdeleting="gvDetails_RowDeleting" onrowediting="gvDetails_RowEditing"
onrowupdating="gvDetails_RowUpdating">
<HeaderStyle BackColor="#df5015" />
<Columns>
<asp:BoundField DataField="UserName" HeaderText="UserName" ReadOnly="true"/>
<asp:BoundField DataField="Email" HeaderText="Email" />
</Columns>
</asp:GridView>
<asp:Label ID="lblResult" runat="server" Font-Bold="true"/>
</div>
</form>
</body>
</html></p>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server">
</asp:Content>
Why does it gives me error? I cant figure it out.
I see that you have place the
<form id="form1" runat="server">
inside a place holder, together with a full page other tags, like the head
I think that this is your error here, the wrong use of place holders. Probably you have one more form on the master page that the one is break the other.
Your code is wrong. You can't have placeholders, forms and the html tag inside a p tag.
Master page HTML :
<%# Master Language="VB" AutoEventWireup="false" CodeBehind="PMS.master.vb" Inherits="PMS.PMS" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%# Register Src="~/Resources/UControl/UserControlMenu.ascx" TagName="UserControlMenu" TagPrefix="uc1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
<link href="Resources/CSS/PostCSS.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100%">
<!--Header-->
<table border="0" background="Resources/Images/bnrCol.jpg"cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="Left" >
<img src="Resources/Images/BnrLeft.jpg" alt="">
</td>
<td align="Right">
<img src="Resources/Images/BnrRight.jpg" alt="">
</td>
</tr>
</table>
<!--Menu-->
<uc1:UserControlMenu ID="UserControlMenu1" runat="server" />
<!--Content-->
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td bgcolor="#EBEBE2" width="100%">
<center>
<%--body+menu here --%>
<table align="center" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td bgcolor="white" width="100%" valign="top">
<%--body here --%>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td rowspan="2">
</td>
</tr>
<tr>
<td valign="top">
<div>
<asp:ContentPlaceHolder ID="BodyContent" runat="server">
</asp:ContentPlaceHolder>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</td>
</tr>
</table>
<!--Footer-->
<%-- <table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td bgcolor="#A1BBCA" height="23" align="center">
<asp:Label ID="Label1" runat="server" CssClass="lblCaptionSmall" ></asp:Label>
</td>
</tr>
</table>--%>
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
Content HTML Code (the page):
<%# Page Language="vb" AutoEventWireup="false" MasterPageFile="~/PMS.Master"
CodeBehind="CreateStatement.aspx.vb" Inherits="PMS.CreateStatement" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="BodyContent" runat="server">
<asp:TextBox CssClass="lblCaption" ID="MainGovSource" runat="server" AutoPostBack="True"
Width="300px" TabIndex="1"></asp:TextBox>
<div id="divAutoComp">
</div>
<asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" MinimumPrefixLength="1"
ServiceMethod="GetOfficialMainCustomer" ServicePath="~/AutoComplete.asmx" TargetControlID="MainGovSource"
BehaviorID="AutoCompleteExtender1" EnableCaching="false" Enabled="True" CompletionSetCount="40"
CompletionListElementID="divAutoComp" CompletionInterval="1">
<Animations>
<OnShow>
<Sequence>
<%-- Make the completion list transparent and then show it --%>
<OpacityAction Opacity="0" />
<HideAction Visible="true" />
<%--Cache the original size of the completion list the first time
the animation is played and then set it to zero --%>
<ScriptAction Script="
// Cache the size and setup the initial size
var behavior = $find('AutoCompleteEx');
if (!behavior._height) {
var target = behavior.get_completionList();
behavior._height = target.offsetHeight - 2;
target.style.height = '0px';
}" />
<%-- Expand from 0px to the appropriate size while fading in --%>
<Parallel Duration=".4">
<FadeIn />
<Length PropertyKey="height" StartValue="0" EndValueScript="$find('AutoCompleteEx')._height" />
</Parallel>
</Sequence>
</OnShow>
<OnHide>
<%-- Collapse down to 0px and fade out --%>
<Parallel Duration=".4">
<FadeOut />
<Length PropertyKey="height" StartValueScript="$find('AutoCompleteEx')._height" EndValue="0" />
</Parallel>
</OnHide>
</Animations>
</asp:AutoCompleteExtender>
</asp:Content>
AutoComplete.asmx
VB Code:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Collections.Generic
Imports System.Collections
Imports PMS.Access
Imports PMS.Common
Imports PMS.Business
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class AutoComplete
Inherits System.Web.Services.WebService
Public Sub AutoComplete()
End Sub
<WebMethod(EnableSession:=True)> _
Public Function GetOfficialMainCustomer(ByVal prefixText As String, ByVal count As Integer) As String()
'--------------
Dim objCustomersBusinessController As New Business.CustomersBusinessController
Dim dsCustomers As New DSCustomer
dsCustomers = objCustomersBusinessController.LoadMainGoverment(-1)
dsCustomers.Customers.ToList()
Dim arrList() As DSCustomer.CustomersRow
arrList = dsCustomers.Customers.Select("CustomerName like '%" & prefixText & "%'")
Return arrList.Where(Function(c) c.CustomerName.ToLower().Contains(prefixText.ToLower())).[Select](Function(p) p.CustomerName).Take(400).ToArray()
End Function
End Class
CustomersBusinessController.vb
Imports PMS.Access
Imports PMS.Common
Imports System.Linq
Imports System.Text
Imports System
Public Class CustomersBusinessController
Inherits BusinessController
Dim objCustomersAccessController As CustomersAccessController = New CustomersAccessController
Public Function LoadMainGoverment(ByVal CustomerID As Integer) As DSCustomer
Return objCustomersAccessController.LoadMainGoverment(CustomerID)
End Function
End Class
CSS :
.autocomplete_completionListElement
{
visibility : hidden;
margin : 0px!important;
background-color : inherit;
color : windowtext;
border : buttonshadow;
border-width : 1px;
border-style : solid;
cursor : 'default';
overflow : auto;
height : 100px;
text-align : left;
list-style-type : none;
}
/* AutoComplete highlighted item */
.autocomplete_highlightedListItem
{
background-color: #ffff99;
color: black;
padding: 1px;
}
/* AutoComplete item */
.autocomplete_listItem
{
background-color : window;
color : windowtext;
padding : 1px;
}
/*trial for the test*/
.ContextMenuPanel
{
border: 1px solid #868686;
z-index: 1000;
background: url(images/menu-bg.gif) repeat-y 0 0 #FAFAFA;
cursor: default;
padding: 1px 1px 0px 1px;
font-size: 11px;
}
.ContextMenuBreak
{
margin:1px 1px 1px 32px;
padding:0;
height:1px;
overflow:hidden;
display:block;
border-top: 1px solid #C5C5C5;
}
a.ContextMenuItem
{
margin: 1px 0 1px 0;
display: block;
color: #003399;
text-decoration: none;
cursor: pointer;
padding: 4px 19px 4px 33px;
white-space: nowrap;
}
a.ContextMenuItem-Selected
{
font-weight: bold;
}
a.ContextMenuItem:hover
{
background-color: #FFE6A0;
color: #003399;
border: 1px solid #D2B47A;
padding: 3px 18px 3px 32px;
}
Note : I am using the AJAX Version 4.1.51116.0
and
I have seen this and that
and tried to work it out ... but nothing is going on ..So Whats Up?
HELP PLEASE .
web service code in c# try it in vb
public string[] GetCompletionList(string prefixText, int count)
{
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\Vinu\\My Documents\\Northwind.mdb");
String instr = prefixText + "%";
OleDbDataAdapter da = new OleDbDataAdapter("select ContactName from Customers where ContactName like '"+instr+"'", conn);
DataTable dt=new DataTable();
da.Fill(dt);
List<string> items = new List<string>(count);
for(int i=0;i<dt.Rows.Count;i++)
{
items.Add(dt.Rows[i].ItemArray[0].ToString());
}
return items.ToArray();
}
IT have been solved Thank GOD... special thanks to #Vinod and #Neha
The problem was in AutoComplete.asmx
<%# WebService Language="vb" CodeBehind="AutoComplete.asmx.vb" Class="attend.AutoComplete" %>
Class="attend.AutoComplete" ... attend is the project that i took AutoComplete.asmx and my
project name is PMS .. I changed it to :
<%# WebService Language="vb" CodeBehind="AutoComplete.asmx.vb" Class="PMS.AutoComplete" %>
and it is working fine now ..
Thanks again guys ..#Vinod and #Neha