I'm getting this error while binding data to data list
too many characters in character literal asp.net
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="android.aspx.cs" Inherits="finalproject.android" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<style type="text/css">
.style1
{
width:900px;
}
.style2
{
width:633px;
text-align:left;
}
.style4
{
width:185px;
text-align:center;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:DataList ID="DataList1" runat="server" DataKeyField="modelid"
style="text-align: center; color: #333333;" RepeatColumns="3"
Width="283px" DataSourceID="SqlDataSource2" CellPadding="3"
BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px"
CellSpacing="1" >
<FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
<ItemStyle BackColor="#DEDFDE" ForeColor="Black" />
<ItemTemplate>
<br />
<div align="left"></div>
<table cellspacing="1" class="style4" style="border:1px ridge #9900FF">
<tr>
<td style="border-bottom-style:ridge; border-width: 1px; border-color: #000000">
<asp:Label ID="Label1" runat="server" Text="<%# Eval('brand') %>"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:ImageButton ID="ImageButton1" runat="server" Height="252px"
ImageUrl="<%# Image %>" style="margin-left: 0px" />
</td>
</tr>
<tr>
<td>
ModelID<asp:Label ID="Label2" runat="server" Text="<%# Eval('modelid') %>"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
CommandArgument="<%# Bind('ModelID') %>" Text="Add to Cart" Width="100%" BorderColor="Black" BorderStyle="Inset" BorderWidth="1px" />
</td>
</tr>
</table>
<br />
</ItemTemplate>
<SelectedItemStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:VISHConnectionString2 %>"
SelectCommand="SELECT [Image], [modelid], [brand] FROM [adddetails]">
</asp:SqlDataSource>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table align="left" class="style2">
<tr>
<td>
<asp:Label ID="Label3" runat="server" style="color: #333333"></asp:Label>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
I'm getting this error while binding data to data list
too many characters in character literal asp.net
"too many characters in character literal" is caused by having a char-literal with too many characters in it.
You have probably mixed up the '-character and the "-character.
The error probably lies in your "android.aspx.cs"-file rather than the .aspx-file that you have provided.
Could you provide the code for that as well?
Well, your problems are right here:
<%# Bind('ModelID') %>
Replace your single-quotes with double-quotes and you will be golden!
<%# Bind("ModelID") %>
Same goes for all your Evals/Binds
Also see these questions:
Why I'm getting CS1012: "Too many characters in character literal" and CS0019?
Too many characters in character literal?
I think the origin of the error is:
Eval('brand')
It tries to convert brand to a character and fails with that error.
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="android.aspx.cs" Inherits="finalproject.android" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<style type="text/css">
.style1
{
width:900px;
}
.style2
{
width:633px;
text-align:left;
}
.style4
{
width:185px;
text-align:center;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:DataList ID="DataList1" runat="server" DataKeyField="modelid"
style="text-align: center; color: #333333;" RepeatColumns="3"
Width="283px" DataSourceID="SqlDataSource2" CellPadding="3"
BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px"
CellSpacing="1" >
<FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
<ItemStyle BackColor="#DEDFDE" ForeColor="Black" />
<ItemTemplate>
<br />
<div align="left"></div>
<table cellspacing="1" class="style4" style="border:1px ridge #9900FF">
<tr>
<td style="border-bottom-style:ridge; border-width: 1px; border-color: #000000">
<asp:Label ID="Label1" runat="server" Text="<%# Eval('brand') %>"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:ImageButton ID="ImageButton1" runat="server" Height="252px"
ImageUrl="<%# Image %>" style="margin-left: 0px" />
</td>
</tr>
<tr>
<td>
ModelID<asp:Label ID="Label2" runat="server" Text="<%# Eval('modelid') %>"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
CommandArgument="<%# Bind('ModelID') %>" Text="Add to Cart" Width="100%" BorderColor="Black" BorderStyle="Inset" BorderWidth="1px" />
</td>
</tr>
</table>
<br />
</ItemTemplate>
<SelectedItemStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:VISHConnectionString2 %>"
SelectCommand="SELECT [Image], [modelid], [brand] FROM [adddetails]">
</asp:SqlDataSource>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table align="left" class="style2">
<tr>
<td>
<asp:Label ID="Label3" runat="server" style="color: #333333"></asp:Label>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
Related
Whenever I try to debug my content page of a master page, another webform which is not a content page runs. I even tried to change the URL after debugging but it didn't work. The URL gets changed automatically.
Please guide me, what could be the problem?
below code is the normal webform which automatically gets run
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Home.aspx.cs" Inherits="Library.Home" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.style1
{
width: 100px;
}
.auto-style1 {
height: 30px;
}
.auto-style2 {
height: 25px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="head">
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/digLib.jpg"
Height="95px" />
</div>
<div id="main"><div id="img">
<table class="style1">
<tr>
<td>
</td>
<td>
<asp:Image ID="Image2" runat="server" ImageUrl="~/Images/lib.jpg"
Height="314px"
style="margin-left: 94px" Width="561px" />
</td>
</tr>
</table>
</div>
<div id="login">
<table class="tbl">
<tr>
<td class="tblhead" colspan="2">
Login Area</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Label ID="lbl" runat="server" Font-Size="11px"
ForeColor="Red"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style1">
UserName :</td>
<td class="auto-style1">
<asp:TextBox ID="txtName" runat="server" CssClass="txt">
</asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server"
ControlToValidate="txtName" ErrorMessage="!!!"
ForeColor="Red"
SetFocusOnError="True"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="lbl">
Password :
</td>
<td>
<asp:TextBox ID="txtPass" runat="server" CssClass="txt"
TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
runat="server"
ControlToValidate="txtPass" ErrorMessage="!!!"
ForeColor="Red"
SetFocusOnError="True"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style2">
</td>
<td class="auto-style2">
<asp:RadioButton ID="rdolibrary" runat="server"
Checked="True"
ForeColor="Green" GroupName="a" Text="Librarian" />
<asp:RadioButton ID="rdosudent" runat="server" ForeColor="Green"
GroupName="a"
Text="Student" />
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnLogin" runat="server" CssClass="btn"
Text="Login"
Width="80px" Font-Size="10pt" OnClick="btnLogin_Click1"
OnClientClick="btnLogin" />
</td>
</tr>
</table>
</div>
</div>
</form>
</body>
</html>
below code is content page of a master page
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master"
AutoEventWireup="true" CodeBehind="AdminPage.aspx.cs"
Inherits="Library.WebForm2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
runat="server">
<asp:Image runat="server" ID="img" ImageUrl="~/Images/lib.jpg" Height="100%"
Width="100%" />
</asp:Content>
below is the master page
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs"
Inherits="Library.Site" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div id="head">
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/digLib.jpg"
Width="500px" Height="100px" />
</div><div id="main"><div id="menu">
<table style="width:100%">
<tr>
<td class="tblhead">
welcome
</td>
</tr>
<tr>
<td bgcolor="#FFA76C" style="text-align: center">
<asp:Label ID="lblname" runat="server" ForeColor="#666666">
</asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button11" runat="server" CssClass="btnmenu"
Text="ADD PUBLICATION"
PostBackUrl="~/Publication.aspx"
CausesValidation="False"
/>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" CssClass="btnmenu"
Text="ADD BOOK"
PostBackUrl="~/Addbook.aspx" CausesValidation="False" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button2" runat="server" CssClass="btnmenu"
Text="BOOK Report"
CausesValidation="False" PostBackUrl="~/bookreport.aspx"
/>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button3" runat="server" CssClass="btnmenu"
Text="ADD Branch"
PostBackUrl="~/Addbranch.aspx" CausesValidation="False"
/>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button4" runat="server" CssClass="btnmenu"
Text="ADD Student"
PostBackUrl="~/AddStudent.aspx" CausesValidation="False"
/>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button5" runat="server" CssClass="btnmenu"
Text="Student Report" CausesValidation="False"
PostBackUrl="~/Studenteport.aspx" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button6" runat="server" CssClass="btnmenu"
Text="Issue Book"
CausesValidation="False" PostBackUrl="~/BookIssue.aspx"
/>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button7" runat="server" CssClass="btnmenu"
Text="Issue Report" CausesValidation="False"
PostBackUrl="~/Issuereport.aspx" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button8" runat="server" CssClass="btnmenu"
Text="Return Book"
CausesValidation="False" PostBackUrl="~/BookReturn.aspx" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button9" runat="server" CssClass="btnmenu"
Text="Panalty"
CausesValidation="False" PostBackUrl="~/Panalty.aspx" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button10" runat="server" CssClass="btnmenu"
Text="LogOut"
CausesValidation="False" onclick="Button10_Click" />
</td>
</tr>
</table>
</div><div id="detail"> <asp:ContentPlaceHolder
id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder></div></div>
</form>
</body>
</html>
I have an ASP.NET project with telerik embedded.
The telerik control I have is RadTabStrip.
The current task is The customer wants the first 2 tabs "Employee" and "general info" to be fill out first before they are able to fill out the other tabs.
Not sure how to implement this. Here is a sample
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" SelectedIndex="0" MultiPageID="RadMultiPage1"
Skin="Telerik" CausesValidation="false">
<Tabs>
<telerik:RadTab runat="server" Selected="True">
<TabTemplate>
<asp:Label ID="Label29" runat="server" Text="<%$ Resources:strings, sample_generalinformation %>" />
<img id="generalInfoErrorIndicator" src="../Images/alert-small.gif" alt="" style="display: none;" />
</TabTemplate>
</telerik:RadTab>
<telerik:RadTab runat="server">
Here is the tab code.
<!-- EMPLOYEE INFORMATION -->
<telerik:RadPageView ID="pvEmployeeInformation" runat="server">
<div id="employeeInfoDiv" runat="server">
<table border="0" cellpadding="3" cellspacing="2">
<tr>
<td colspan="2">
<h1>
<asp:Label ID="Label34" runat="server" Text="<%$ Resources:strings, observed_employee_information %>" /></h1>
</td>
</tr>
<tr>
<td style="text-align: right;">
<asp:Label ID="Label12" runat="server" Text="<%$ Resources:strings, employee_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:EmployeeSearch ID="employeeSearch" runat="server" OnClientEmployeeSelected="employeeSelected"
ClientValidationFunction="validateEmployee" ValidationGroup="employeeInfo" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<table border="0" cellpadding="3" cellspacing="2">
<tr>
<td>
<asp:CheckBox ID="areaSampleCheckBox" runat="server" Text="<%$ Resources:strings, labels_areasample %>"
ValidationGroup="employeeInfo" />
</td>
<td>
<asp:CheckBox ID="unknownEmployeeCheckBox" runat="server" Text="<%$ Resources:strings, labels_unknownemployee %>"
ValidationGroup="employeeInfo" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="text-align: right;">
<asp:Label ID="Label13" runat="server" Text="<%$ Resources:strings, job_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:JobSearch ID="jobSearch" runat="server" ValidationGroup="employeeInfo" ClientValidationFunction="validateJob"
OnClientJobSelected="jobSelected" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:CheckBox ID="unknownJobCheckBox" runat="server" Text="<%$ Resources:strings, labels_unknownjob %>" />
</td>
</tr>
<tr>
<td style="text-align: right;">
<asp:Label ID="Label14" runat="server" Text="<%$ Resources:strings, shift_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewShiftDropDown ID="shiftDropDown" runat="server" ValidationGroup="employeeInfo" />
</td>
</tr>
<tr>
<td style="text-align: right;">
<asp:Label ID="Label15" runat="server" Text="<%$ Resources:strings, shiftlength_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewShiftLengthDropDown ID="shiftLengthDropDown" runat="server" ValidationGroup="employeeInfo" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:ValidationSummary ID="employeeInformationValidationSummary" runat="server" Font-Bold="True"
ForeColor="Red" HeaderText="<%$ Resources:strings, validationsummary_nextwizard_msg %>"
ValidationGroup="employeeInfo" />
</td>
</tr>
</table>
</div>
</telerik:RadPageView>
And another
<!-- GENERAL INFORMATION -->
<telerik:RadPageView ID="pvGeneralInformation" runat="server">
<div id="generalInfoDiv" runat="server">
<table border="0" cellpadding="3" cellspacing="2">
<tr>
<td colspan="4">
<h1>
<asp:Label ID="Label16" runat="server" Text="<%$ Resources:strings, general_information %>" /></h1>
</td>
</tr>
<tr valign="top">
<td style="text-align: right;">
<asp:Label ID="Label1" runat="server" Text="<%$ Resources:strings, facility_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:FacilitySearch ID="facilitySearch" runat="server" ValidationGroup="generalInfo"
OnClientFacilitySelected="facilitySelected" OnClientFacilityCleared="facilityCleared"
AutoPostBack="true" />
</td>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label7" runat="server" Text="<%$ Resources:strings, samplelength_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewSampleLengthDropDown ID="sampleLengthDropDown" runat="server" ValidationGroup="generalInfo" />
</td>
</tr>
<tr valign="top">
<td style="text-align: right; padding-left: 10px;">
<asp:Label ID="Label2" runat="server" Text="<%$ Resources:strings, sampledate_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewDateEntry ID="sampleDate" runat="server" ValidationGroup="generalInfo"
ValidateDateNotInFuture="true" />
</td>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label8" runat="server" Text="<%$ Resources:strings, samplemethod_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:SampleMethodSearch ID="sampleMethodSearch" runat="server" ValidationGroup="generalInfo"
OnClientSampleMethodSelected="sampleMethodSelected" />
</td>
</tr>
<tr valign="top">
<td style="text-align: right;">
<asp:Label ID="Label3" runat="server" Text="<%$ Resources:strings, sampletype_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewSampleTypeDropDown ID="sampleTypeDropDown" runat="server" ValidationGroup="generalInfo"
FormDesignator="PassiveBadge" />
</td>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label69" runat="server" Text="<%$ Resources:strings, samplenumber_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<telerik:RadTextBox ID="sampleNumberTextBox" runat="server" Skin="Telerik" Width="200px" /> <asp:Image
ID="sampleNumberInfoImage" runat="server" ImageUrl="~/Images/info.png" ToolTip="<%$ Resources:strings, samplenumber_info %>" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator19" runat="server"
ControlToValidate="sampleNumberTextBox" ErrorMessage="<%$ Resources:strings, validations_fieldlength_16 %>"
ToolTip="<%$ Resources:strings, validations_fieldlength_16 %>" ValidationExpression="<%$ AppSettings:Length16ValidationExpression %>"
ValidationGroup="generalInfo" />
</td>
</tr>
<tr valign="top">
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label4" runat="server" Text="<%$ Resources:strings, occupationalhealthlimit_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:OelSearch ID="oelSearch" runat="server" ValidationGroup="generalInfo" OnClientOelSelected="oelSelected" />
</td>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label10" runat="server" Text="<%$ Resources:strings, labsamplenumber_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<telerik:RadTextBox ID="labSampleNumberTextBox" runat="server" Skin="Telerik" Width="175px" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="labSampleNumberTextBox"
ErrorMessage="<%$ Resources:strings, labsamplenumber_length %>" ToolTip="<%$ Resources:strings, labsamplenumber_length %>"
ValidationExpression="<%$ AppSettings:Length64ValidationExpression %>" ValidationGroup="generalInfo" />
</td>
</tr>
<tr valign="top">
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label67" runat="server" Text="<%$ Resources:strings, exposuregroup_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:ExposureGroupSearch ID="exposureGroupSearch" runat="server" ValidationGroup="generalInfo" />
</td>
<td colspan="2" align="center">
<table border="0" cellpadding="3" cellspacing="2">
<tr>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label11" runat="server" Text="<%$ Resources:strings, stelsample_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<asp:CheckBox ID="stelSampleCheckBox" runat="server" />
</td>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label68" runat="server" Text="<%$ Resources:strings, labels_ceiling %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<asp:CheckBox ID="ceilingSampleCheckBox" runat="server" />
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label5" runat="server" Text="<%$ Resources:strings, collectinguser_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:AdminUserSearch ID="adminUserSearch" runat="server" ValidationGroup="generalInfo" />
</td>
<td style="text-align: right;">
<asp:Label ID="Label18" runat="server" Text="<%$ Resources:strings, samplingdevice_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewSamplingDeviceDropDown ID="samplingDeviceDropDown" runat="server" />
</td>
</tr>
<tr valign="top">
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label6" runat="server" Text="<%$ Resources:strings, samplestrategy_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewSampleStrategyDropDown ID="sampleStrategyDropDown" runat="server" ValidationGroup="generalInfo" />
</td>
<td style="text-align: right;">
<asp:Label ID="Label19" runat="server" Text="<%$ Resources:strings, blanknumber_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<telerik:RadTextBox ID="blankNumberTextBox" runat="server" Skin="Telerik" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="blankNumberTextBox"
ErrorMessage="<%$ Resources:strings, blanknumber_required %>" ToolTip="<%$ Resources:strings, blanknumber_required %>"
ValidationGroup="generalInfo" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="blankNumberTextBox"
ErrorMessage="<%$ Resources:strings, blanknumber_length %>" ToolTip="<%$ Resources:strings, blanknumber_length %>"
ValidationExpression="<%$ AppSettings:Length64ValidationExpression %>" ValidationGroup="generalInfo" />
</td>
</tr>
<tr valign="top">
<td colspan="4">
<asp:ValidationSummary ID="generalInformationValidationSummary" runat="server" Font-Bold="True"
ForeColor="Red" HeaderText="<%$ Resources:strings, validationsummary_nextwizard_msg %>"
ValidationGroup="generalInfo" />
</td>
</tr>
</table>
</div>
</telerik:RadPageView>
It is very difficult to give you a solution based on your own code because of all the custom references. However, the controls in the various tabs can be accessed directly from code behind. I made a test on a 3 tabs RadTabStrip playing on enabling tab2.
UPDATE
Something went wrong with the previous example. I had to use some Javascript to resolve the issue on the client side. I tested this code and it is working. Basically there are two textboxes on the first tab and a button that is disabled by default. The button gets enabled only if text is in both textboxes (I understood you have more than one control on the tab that needs to be filled-in so this is a good example). Then clicking the button you enable tab 2. You can rewrite the javascript to enable directly the tabs when your fields/controls on the first and second tab are satisfying the requirements.
In PAGE_LOAD set the tabs that should not be visible or enabled
protected void Page_Load(object sender, EventArgs e)
{
//RadTabStrip1.Tabs[2].Visible = false;
RadTabStrip1.Tabs[2].Enabled = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
RadTabStrip1.Tabs[2].Enabled = true;
}
Here is the rest of the code with the script
<body>
<form id="form1" runat="server">
<script language="javascript" type="text/javascript">
//function to enable button if two textboxes contains text
function SetButtonStatus(sender, target) {
var first = document.getElementById('<%=TextBox1.ClientID %>');
var second = document.getElementById('<%=TextBox2.ClientID %>');
//Condition to check whether user enters text in two textboxes or not
if ((sender.value.length >= 1 && first.value.length >= 1) && (sender.value.length >= 1 && second.value.length >= 1))
document.getElementById(target).disabled = false;
else
document.getElementById(target).disabled = true;
}
</script>
<telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
<div>
<telerik:RadTabStrip RenderMode="Lightweight" runat="server" ID="RadTabStrip1" MultiPageID="RadMultiPage1" SelectedIndex="0" Skin="Silk">
<Tabs>
<telerik:RadTab Text="I am Tab 0" Width="200px"></telerik:RadTab>
<telerik:RadTab Text="I am Tab 1" Width="200px"></telerik:RadTab>
<telerik:RadTab Text="I am Tab 2" Width="200px"></telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage runat="server" ID="RadMultiPage1" SelectedIndex="0" CssClass="outerMultiPage">
<telerik:RadPageView runat="server" ID="RadPageView1">
<telerik:RadTabStrip RenderMode="Lightweight" runat="server" ID="RadTabStrip2" MultiPageID="RadMultiPage2"
Orientation="VerticalLeft" Skin="Silk" Width="50px" Height="355px" SelectedIndex="0">
</telerik:RadTabStrip>
<telerik:RadMultiPage runat="server" ID="RadMultiPage2" SelectedIndex="0" CssClass="innerMultiPage">
<telerik:RadPageView runat="server" ID="PageView1">
<div>
<asp:TextBox ID="TextBox1" runat="server" onkeyup="SetButtonStatus(this,'btnButton')"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" onkeyup="SetButtonStatus(this,'btnButton')"></asp:TextBox>
<asp:Button ID="btnButton" runat="server" Text="Button" Enabled="false" OnClick="Button1_Click" />
</div>
</telerik:RadPageView>
</telerik:RadMultiPage>
</telerik:RadPageView>
<telerik:RadPageView runat="server" ID="RadPageView2">
<div></div>
<div>
<p>Something</p>
</div>
</telerik:RadPageView>
<telerik:RadPageView runat="server" ID="RadPageView3">
<div>
<p>Again something</p>
</div>
</telerik:RadPageView>
</telerik:RadMultiPage>
</div>
</form>
</body>
I store all data in MySQL and display it's some colums in gridview. Gridview's delete button works fine. I would like to edit datas so created HyperLink. it navigates another url and gets values from MySQL DB and sets textboxes, textareas. Everything is fine until this time but I try to edit values in new page it sets old values in DB. How i can solve this problem?
This my Main Page which has gridview and delete button, hyperlink KayitGoruntule.aspx;
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="KayitGoruntule.aspx.cs" Inherits="gop.KayitGoruntule" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.string {
text-align: left;
}
</style>
</head>
<body>
<center><asp:Image ID="Banner" runat="server" ImageUrl="images/logo.png" Height="88px" Width="509px"></asp:Image></center>
<form id="form1" runat="server">
<br />
<div>
<asp:GridView ID="gvMysqlData" runat="server" CssClass="string"
SelectedIndex="0" DataKeyNames="id"
ShowHeaderWhenEmpty="True" OnRowDeleting="gvMysqlData_RowDeleting" Height="95px" Width="492px" CellPadding="4" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="" ItemStyle-Width="15%">
<ItemTemplate>
<asp:HyperLink ID="hpr1" runat="server" NavigateUrl='<%# string.Format("KayitAyrinti.aspx?id={0}",Eval("id")) %>'>
<img src="images/edit.png" />
</asp:HyperLink>
</ItemTemplate>
<ItemStyle Width="15%" />
</asp:TemplateField>
<asp:CommandField ShowDeleteButton="True" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
</div>
</form>
</body>
</html>
Navigated Url's page KayitAyrinti.aspx;
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="KayitAyrinti.aspx.cs" Inherits="gop.KayitAyrinti" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style2 {
height: 23px;
width: 217px;
}
.auto-style1 {
height: 23px;
width: 271px;
}
.degistir-button {
background:#7ab752;
margin:1px auto 0px;
text-align:right;
color:#FFF;
/*border:none;
border-top-left-radius:4px;
border-bottom-left-radius:4px;*/
-webkit-transition:background 0.5s;
}
.degistir-button:hover {
background:#DC3F42 #81c356;
}
.kaydet-button {
background:#7ab752;
margin:auto;
margin-right:4px;
margin-left:60px;
text-align:right;
color:#FFF;
/* border:none;
border-top-left-radius:40px;
border-bottom-left-radius:40px;
*/
-webkit-transition:background 0.5s;
}
.kaydet-button:hover {
background:#DC3F42 #81c356;
}
</style>
</head>
<body>
<center><asp:Image ID="Banner" runat="server" ImageUrl="images/logo.png" Height="88px" Width="509px"></asp:Image></center>
<form id="register" runat="server">
<br />
<div>
<table align="center">
<tr>
<td class="auto-style1" >
<asp:Label ID="lbl_ayrintiYetkiliAdSoyad" runat="server" Text="Yetkili Adı Soyad :" Font-Bold="True" Font-Names="Book Antiqua" ></asp:Label>
</td>
<td class="auto-style2">
<asp:TextBox ID="ayrintiYetkiliAdSoyad_txt" runat="server" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style1">
<asp:Label ID="lbl_ayrintiGorusmeYapilanOkul" runat="server" Text="Görüşme Yapılan Okul :" Font-Bold="True" Font-Names="Book Antiqua"></asp:Label>
</td>
<td class="auto-style2">
<asp:RadioButtonList ID="RadioButtonList_ayrintiGorusmeYapilanOkul" runat="server" Width="174px">
<asp:ListItem>Seyrantepe Şube 1</asp:ListItem>
<asp:ListItem>Seyrantepe Şube 2</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td class="auto-style1">
<asp:Label ID="lbl_ayrintiveliAdSoyad" runat="server" Text="Veli Adı Soyadı :" Font-Bold="True" Font-Names="Book Antiqua"></asp:Label>
</td>
<td class="auto-style2">
<asp:TextBox ID="ayrintiVeliAdiSoyadi_txt" runat="server" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style1">
<asp:Label ID="lbl_veliTel" runat="server" Text="Veli Telefon Numarası :" Font-Bold="True" Font-Names="Book Antiqua"></asp:Label>
</td>
<td class="auto-style2">
<asp:TextBox ID="ayrintiVeliTel_txt" runat="server" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style1">
<asp:Label ID="lbl_ikametAdres" runat="server" Text="İkamet Adresi :" Font-Bold="True" Font-Names="Book Antiqua"></asp:Label>
</td>
<td class="auto-style2">
<textarea id="ayrintiIkametAdres_txt" rows="5" cols="26" runat="server"></textarea>
</td>
</tr>
<tr>
<td class="auto-style1">
<asp:Label ID="lbl_ogrenciAdSoyad" runat="server" Text="Öğrenci Adı Soyadı :" Font-Bold="True" Font-Names="Book Antiqua"></asp:Label>
</td>
<td class="auto-style2">
<asp:TextBox ID="ayrintiOgrenciAdSoyad_txt" runat="server" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style1">
<asp:Label ID="lbl_ogrenciTel" runat="server" Text="Öğrenci Telefon Numarası :" Font-Bold="True" Font-Names="Book Antiqua"></asp:Label>
</td>
<td class="auto-style2">
<asp:TextBox ID="ayrintiOgrenciTel_txt" runat="server" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style1">
<asp:Label ID="lbl_ilgilendigiBolum" runat="server" Text="İlgilendiği Bölüm :" Font-Bold="True" Font-Names="Book Antiqua"></asp:Label>
</td>
<td class="auto-style2">
<asp:RadioButtonList ID="RadioButtonList_ayrintiIlgilendigiBolum" runat="server" Width="174px">
<asp:ListItem>Hemşire Yardımcılığı</asp:ListItem>
<asp:ListItem>Sağlık Bakım Teknisyenliği</asp:ListItem>
<asp:ListItem>Anadolu Lisesi</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td class="auto-style1">
<asp:Label ID="lbl_verilenFiyat" runat="server" Text="Verilen Fiyat :" Font-Bold="True" Font-Names="Book Antiqua"></asp:Label>
</td>
<td class="auto-style2">
<asp:TextBox ID="ayrintiVerilenFiyat_txt" runat="server" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style1">
<asp:Label ID="lbl_gorusmeSonucu" runat="server" Text="Görüşme Sonucu :" Font-Bold="True" Font-Names="Book Antiqua"></asp:Label>
</td>
<td class="auto-style2">
<asp:TextBox ID="ayrintiGorusmeSonucu_txt" runat="server" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style1">
<asp:Label ID="lbl_gorusmeNotlari" runat="server" Text="Görüşme Notları :" Font-Bold="True" Font-Names="Book Antiqua"></asp:Label>
</td>
<td class="auto-style2">
<textarea id="ayrintiGorusmeNotlari_txt" rows="5" cols="26" runat="server"></textarea>
</td>
</tr>
<tr>
<td class="auto-style1">
<asp:Label ID="Label1" runat="server" Text="" Font-Bold="True" Font-Names="Book Antiqua"></asp:Label>
</td>
<td class="auto-style2">
<asp:button id="degistir" runat="server" text="Değiştir" class="degistir-button" OnClick="degistir_Click"/>
<asp:Button ID="kaydet" runat="server" Text="Kaydet" CssClass="kaydet-button" OnClick="kaydet_Click" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
This class is which shows values and try to update with degistir_Click,
KayitAyrinti.aspx.cs;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace gop
{
public partial class KayitAyrinti : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["kullanici"] != null)
{
Response.Write("Hoşgeldiniz..." + Session["kullanici"]);
Response.Redirect("KayitAyrinti.aspx");
}
else
{
// Response.Write("Giriş Yapınız.");
}
string connectionString = "xxx;Database=xxx;Uid=xxxx;Pwd=xxx;";
using (MySqlConnection cn = new MySqlConnection(connectionString))
{
string[] keys = Request.QueryString.GetValues("id");
String id = keys[0];
MySqlCommand cmd = new MySqlCommand("select id, yetkiliAdSoyad,gorusmeYapilanOkul,veliAdSoyad, veliTel, ikametAdres, ogrenciAdSoyad, ogrenciTel, ilgilendigiBolum,verilenFiyat,gorusmeSonucu,gorusmeNotlari from Kayitlar where id=" + id + "", cn);
try
{
cn.Open();
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
ayrintiYetkiliAdSoyad_txt.Text = (reader["yetkiliAdSoyad"].ToString());
RadioButtonList_ayrintiIlgilendigiBolum.SelectedValue = (reader["gorusmeYapilanOkul"].ToString());
ayrintiVeliAdiSoyadi_txt.Text = (reader["veliAdSoyad"].ToString());
ayrintiVeliTel_txt.Text = (reader["veliTel"].ToString());
ayrintiIkametAdres_txt.InnerText = (reader["ikametAdres"].ToString());
ayrintiOgrenciAdSoyad_txt.Text= (reader["ogrenciAdSoyad"].ToString());
ayrintiOgrenciTel_txt.Text = (reader["ogrenciTel"].ToString());
RadioButtonList_ayrintiIlgilendigiBolum.SelectedValue= (reader["ilgilendigiBolum"].ToString());
ayrintiVerilenFiyat_txt.Text= (reader["verilenFiyat"].ToString());
ayrintiGorusmeSonucu_txt.Text= (reader["gorusmeSonucu"].ToString());
ayrintiGorusmeNotlari_txt.InnerText = (reader["gorusmeNotlari"].ToString());
}
}
}
catch (Exception ex)
{
}
}
}
protected void degistir_Click(object sender, EventArgs e)
{
string connectionString = "Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx;";
using (MySqlConnection cn = new MySqlConnection(connectionString))
{
string[] keys = Request.QueryString.GetValues("id");
String id = keys[0];
cn.Open();
MySqlCommand komut = new MySqlCommand("UPDATE Kayitlar SET yetkiliAdSoyad=#ayrintiYetkiliAdSoyad, gorusmeYapilanOkul = #ayrintiGorusmeYapilanOkul,"+
" veliAdSoyad = #ayrintiVeliAdSoyad ,veliTel = #ayrintiVeliTel,ikametAdres = #ayrintiIkametAdres ,ogrenciAdSoyad = #ayrintiOgrenciAdSoyad, " +
"ogrenciTel=#ayrintiOgrenciTel,ilgilendigiBolum = #ayrintiIlgilendigiBolum,verilenFiyat=#ayrintiVerilenFiyat,gorusmeSonucu=#ayrintiGorusmeSonucu,gorusmeNotlari=#ayrintiGorusmeNotlari", cn);
komut.Parameters.AddWithValue("#ayrintiYetkiliAdSoyad", ayrintiYetkiliAdSoyad_txt.Text);
komut.Parameters.AddWithValue("#ayrintiGorusmeYapilanOkul", RadioButtonList_ayrintiGorusmeYapilanOkul.SelectedValue);
komut.Parameters.AddWithValue("#ayrintiVeliAdSoyad", ayrintiVeliAdiSoyadi_txt.Text);
komut.Parameters.AddWithValue("#ayrintiVeliTel", ayrintiVeliTel_txt.Text);
komut.Parameters.AddWithValue("#ayrintiIkametAdres", ayrintiIkametAdres_txt.InnerText);
komut.Parameters.AddWithValue("#ayrintiOgrenciAdSoyad", ayrintiOgrenciAdSoyad_txt.Text);
komut.Parameters.AddWithValue("#ayrintiOgrenciTel", ayrintiOgrenciTel_txt.Text);
komut.Parameters.AddWithValue("#ayrintiIlgilendigiBolum", RadioButtonList_ayrintiIlgilendigiBolum.SelectedValue);
komut.Parameters.AddWithValue("#ayrintiVerilenFiyat", ayrintiVerilenFiyat_txt.Text);
komut.Parameters.AddWithValue("#ayrintiGorusmeSonucu", ayrintiGorusmeSonucu_txt.Text);
komut.Parameters.AddWithValue("#ayrintiGorusmeNotlari", ayrintiGorusmeNotlari_txt.InnerText);
komut.ExecuteNonQuery();
Response.Redirect("KayitGoruntule.aspx");
komut.Dispose();
}
}
protected void kaydet_Click(object sender, EventArgs e)
{
}
}
}
The textboxes on your form are being populated with their database defaults in the Page_Load event. This is fine the first time through; however, when you click your 'degistir' button, a "postback" occurs, and Page_Load fires again and repopulates those defaults, losing whatever changes were submitted. Keep in mind that Page_Load fires before any control click events.
To fix this, you need to check for IsPostback in Page_Load to prevent your loader from firing on the update. If IsPostback is true, inhibit the load of the defaults from your database. This, in turn, should allow the update to occur with the updated data provided on your form. Something along these lines:
// code snipped...
if (Session["kullanici"] != null)
{
Response.Write("Hoşgeldiniz..." + Session["kullanici"]);
Response.Redirect("KayitAyrinti.aspx");
}
else
{
// Response.Write("Giriş Yapınız.");
}
if (!IsPostback) // <-- Add this check
{
string connectionString = "xxx;Database=xxx;Uid=xxxx;Pwd=xxx;";
using (MySqlConnection cn = new MySqlConnection(connectionString))
{
string[] keys = Request.QueryString.GetValues("id");
/// rest of code snipped
Also, be sure to modify your UPDATE statement to include a WHERE clause that limits the UPDATE to only that record with the desired ID. As it is, ALL your records will be updated!
I have a listview control and in layout template, i have linkbuttons. Now what i want to do. i have a span with each linkbutton. i want to give css class while we click on linkbutton. my html code is as follow:
<asp:ListView ID="lst_CallType" runat="server" ItemPlaceholderID="tr" OnItemDataBound="lst_CallType_ItemDataBound">
<LayoutTemplate>
<table cellspacing="0">
<tr class="hdrRowColor1">
<td align="left" width="500px">
<asp:LinkButton ID="lnk_Name" runat="server" ValidationGroup="vgSearch" OnClientClick="changeSortState();"
CommandArgument="tblCallTypenew.CallType" OnClick="lnk_Sort">Name</asp:LinkButton>
<span id="imgSortPosition" class="sortNotSelected"></span>
</td>
<td align="left" width="80px">
<asp:LinkButton ID="lnk_Status" runat="server" CommandArgument="tblCallTypenew.isactive"
ValidationGroup="vgSearch" OnClick="lnk_Sort">Status</asp:LinkButton>
<span id="Span1" class="sortNotSelected"></span>
</td>
<td align="left" width="200px">
<asp:LinkButton ID="lnk_CreatedOn" runat="server" CommandArgument="tblCallTypenew.CreatedDate"
ValidationGroup="vgSearch" OnClick="lnk_Sort">Created On</asp:LinkButton>
<span id="Span2" class="sortNotSelected"></span>
</td>
<td align="left" width="200px">
<asp:LinkButton ID="lnk_LastModfiedOn" runat="server" CommandArgument="tblCallTypenew.ModifiedDate"
ValidationGroup="vgSearch" OnClick="lnk_Sort">Last Modified On</asp:LinkButton>
<span id="Span3" class="sortNotSelected"></span>
</td>
<td align="left" width="200px">
<asp:LinkButton ID="lnk_CreatedBy" runat="server" CommandArgument="tblUserNew.FirstName"
ValidationGroup="vgSearch" OnClick="lnk_Sort">Created By</asp:LinkButton>
<span id="Span4" class="sortNotSelected"></span>
</td>
<td align="left" width="200px">
<%--<asp:LinkButton ID="lnkCreatedDate" runat="server" CommandArgument="tblUserActivities.CreatedDate"
OnClick="lnk_Sort">Created Date</asp:LinkButton>--%>
<asp:LinkButton ID="lnk_LastModfiedBy" runat="server" CommandArgument="v.FirstName"
ValidationGroup="vgSearch" OnClick="lnk_Sort">Modified By</asp:LinkButton>
<span id="Span5" class="sortNotSelected"></span>
</td>
<td align="left" style="border-right: 1px solid #6398cc">
Activity
<div style="width: 50px; float: right;">
</div>
</td>
</tr>
<tr id="tr" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr class='<%# Convert.ToBoolean(Container.DataItemIndex % 2) ? "EvenRowColor" : "OddRowColor" %>'>
<td align="left">
<asp:Label ID="lblDeptId" runat="server" Text='<%# Eval("ID")%>' Visible="false"></asp:Label>
<%# Eval("Calltype")%>
</td>
<td align="left">
<asp:Label ID="lbl_Status" runat="server" Style="display: none;" Text='<%# Eval("IsActive")%>'></asp:Label>
<asp:ImageButton ID="imgbtnStatus" runat="server" CommandArgument='<%# Eval("id") %>'
OnClick="imgbtnStatus_Onclick" />
</td>
<td align="left">
<%# Eval("CreatedDate")%>
</td>
<td align="left">
<%# Eval("ModifiedDate") %>
</td>
<td align="left">
<%# Eval("CreatedBy")%>
</td>
<td align="left">
<%# Eval("ModifiedBy")%>
</td>
<td>
<asp:Label ID="lblCallType" runat="server" Style="display: none;" Text='<%# Eval("Calltype")%>'></asp:Label>
<asp:ImageButton ID="imgbtnEdit" runat="server" ImageUrl="~/App_Themes/ThemeNew/Images/edit.png"
ToolTip="Edit Details" CommandArgument='<%# Eval("ID") %>' OnClick="imgbtnEdit_OnClick" />
<asp:ImageButton ID="imgbtnDelete" runat="server" ImageUrl="~/App_Themes/ThemeNew/Images/delete.png"
ToolTip="Delete" Style="display: none;" CommandArgument='<%# Eval("id") %>' OnClientClick="return confirm('Are you sure you want to delete the Call type?');"
OnClick="imgbtnDelete_OnClick" />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
Actually i want to show sort images while user click on linkbuttons.And i want to do it by code behind.
My .cs code is as follow:
protected void lnk_Sort(object sender, EventArgs e)
{
LinkButton lnk = (LinkButton)sender;
string arg = lnk.CommandArgument.ToString();
ViewState["sortCol"] = arg;
GetSortDirection();
BindData(ViewState["sortCol"].ToString(), ViewState["sortDir"].ToString(), Convert.ToInt32(ViewState["nmbr"]), Pager.PageSize);
}
private void GetSortDirection()
{
if (Convert.ToString(ViewState["sortDir"]) == "Desc")
{
ViewState["sortDir"] = "asc";
}
else
{
ViewState["sortDir"] = "Desc";
}
}
You can do a findcontrol in Listview_sorting event
i have done it with a silly trick
my html code is:
<asp:ListView ID="lst_CallType" runat="server" ItemPlaceholderID="tr" OnItemDataBound="lst_CallType_ItemDataBound">
<LayoutTemplate>
<table cellspacing="0">
<tr class="hdrRowColor1">
<td width="35px" align="left">
S.No
</td>
<td align="left" width="300px">
<asp:LinkButton ID="lnk_Name" runat="server" ValidationGroup="vgSearch" CommandArgument="tblCallTypenew.CallType"
OnClick="lnk_Sort">Name</asp:LinkButton>
<asp:Image ID="img_lnk_Name" Visible="false" runat="server" />
</td>
<td align="left" width="150px">
<asp:LinkButton ID="lnk_CreatedBy" runat="server" CommandArgument="tblUserNew.FirstName"
ValidationGroup="vgSearch" OnClick="lnk_Sort">Created By</asp:LinkButton>
<asp:Image ID="img_lnk_CreatedBy" Visible="false" runat="server" />
</td>
<td align="left" width="120px">
<asp:LinkButton ID="lnk_CreatedOn" runat="server" CommandArgument="tblCallTypenew.CreatedDate"
ValidationGroup="vgSearch" OnClick="lnk_Sort">Created On</asp:LinkButton>
<asp:Image ID="img_lnk_CreatedOn" Visible="false" runat="server" />
</td>
<td align="left" width="150px">
<%--<asp:LinkButton ID="lnkCreatedDate" runat="server" CommandArgument="tblUserActivities.CreatedDate"
OnClick="lnk_Sort">Created Date</asp:LinkButton>--%>
<asp:LinkButton ID="lnk_LastModfiedBy" runat="server" CommandArgument="v.FirstName"
ValidationGroup="vgSearch" OnClick="lnk_Sort">Last Modified By</asp:LinkButton>
<asp:Image ID="img_lnk_LastModfiedBy" Visible="false" runat="server" />
</td>
<td align="left" width="120px">
<asp:LinkButton ID="lnk_LastModfiedOn" runat="server" CommandArgument="tblCallTypenew.ModifiedDate"
ValidationGroup="vgSearch" OnClick="lnk_Sort">Last Modified On</asp:LinkButton>
<asp:Image ID="img_lnk_LastModfiedOn" Visible="false" runat="server" />
</td>
<td align="center" width="55px">
<asp:LinkButton ID="lnk_Status" runat="server" CommandArgument="tblCallTypenew.isactive"
ValidationGroup="vgSearch" OnClick="lnk_Sort">Status</asp:LinkButton>
<asp:Image ID="img_lnk_Status" Visible="false" runat="server" />
</td>
<td align="center" width="50px" style="border-right: 1px solid #6398cc">
Activity
<%-- <div style="width: 50px; float: right;">
</div>--%>
</td>
</tr>
<tr id="tr" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr class='<%# Convert.ToBoolean(Container.DataItemIndex % 2) ? "EvenRowColor" : "OddRowColor" %>'>
<td align="left" valign="middle">
<%# Container.DataItemIndex+1 %>.
</td>
<td align="left">
<asp:Label ID="lblDeptId" runat="server" Text='<%# Eval("ID")%>' Visible="false"></asp:Label>
<%# Eval("Calltype")%>
</td>
<td align="left">
<%# Eval("CreatedBy")%>
</td>
<td align="left">
<%# Convert.ToDateTime(Eval("CreatedDate")).ToString("MMM dd, yyyy")%>
</td>
<td align="left">
<%# Eval("ModifiedBy")%>
</td>
<td align="left">
<%# Convert.ToDateTime(Eval("ModifiedDate")).ToString("MMM dd, yyyy")%>
</td>
<td align="center">
<asp:Label ID="lbl_Status" runat="server" Style="display: none;" Text='<%# Eval("IsActive")%>'></asp:Label>
<asp:ImageButton ID="imgbtnStatus" runat="server" CommandArgument='<%# Eval("id") %>'
OnClick="imgbtnStatus_Onclick" />
</td>
<td class="last" align="center">
<asp:Label ID="lblCallType" runat="server" Style="display: none;" Text='<%# Eval("Calltype")%>'></asp:Label>
<asp:ImageButton ID="imgbtnEdit" runat="server" ImageUrl="~/App_Themes/ThemeNew/Images/edit.png"
ToolTip="Edit Details" CommandArgument='<%# Eval("ID") %>' OnClick="imgbtnEdit_OnClick" />
<asp:ImageButton ID="imgbtnDelete" runat="server" ImageUrl="~/App_Themes/ThemeNew/Images/delete.png"
ToolTip="Delete" Style="display: none;" CommandArgument='<%# Eval("id") %>' OnClientClick="return confirm('Are you sure you want to delete the Call type?');"
OnClick="imgbtnDelete_OnClick" />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
My code behind code is:
protected void lnk_Sort(object sender, EventArgs e)
{
LinkButton lnk = (LinkButton)sender;
string arg = lnk.CommandArgument.ToString();
ViewState["sortCol"] = arg;
GetSortDirection();
BindData(ViewState["sortCol"].ToString(), ViewState["sortDir"].ToString(), Convert.ToInt32(ViewState["nmbr"]), Pager.PageSize);
string name = lnk.ID;
Image img = (Image)(lst_CallType.FindControl("img_" + name));
if (img != null)
{
SetSortOrderImage(img, ViewState["sortDir"].ToString());
}
}
private void SetSortOrderImage(Image image, String sortorder)
{
if (sortorder == "asc")
{
image.Visible = true;
image.ImageUrl = "../App_Themes/ThemeNew2/images/up.png";
}
else if (sortorder == "Desc")
{
image.Visible = true;
image.ImageUrl = "../App_Themes/ThemeNew2/images/down.png";
}
}
i use modal popup extender to show my details in another separate window it is a panel contains some controls the problem is ::
when i click on my button which contains::
the Show() method the parent page just frozen and no popup appears at all on the other side i have a grid view when i click on the last button on it the popup appears where the other buttons on the grid view make the same behavior of my first button , i donot know what is the problem my panel visibility = true and no setting in my behind code..i view the source and i find the panel with its contents then why the popup window doesnot appear..i search alot but i donot find a solution to my problem ..
my aspx::
<asp:Panel id="master_editMode" runat="server" >
<div id="masterDiv" style="width:98%" dir="rtl">
<div id="masterControls" align="center">
<table border="0" width="98%">
<tr>
<td align="center" dir="rtl">
<asp:ObjectDataSource ID="ObjDS_AllTasks" runat="server"
SelectMethod="Get_All_Tasks" TypeName="DocumentFlowModuleDTO.TaskDTO">
</asp:ObjectDataSource>
<asp:HiddenField ID="hd_Task_Code" runat="server" />
<table>
<tr>
<td>
<asp:Label ID="Label11" runat="server" Text="Search for Task" Visible="False"></asp:Label>
</td>
<td align="right">
<asp:TextBox ID="txt_Search" runat="server" AutoPostBack="True"
ontextchanged="txt_Search_TextChanged" Width="200px" Visible="False"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td colspan="3">
<asp:GridView ID="grd_AllTasks" runat="server" AllowPaging="True"
AutoGenerateColumns="False" CssClass="Alternating" DataKeyNames="task_code"
DataSourceID="ObjDS_AllTasks"
onpageindexchanging="grd_AllTasks_PageIndexChanging"
onrowdatabound="grd_AllTasks_RowDataBound" style="margin-right: 0px">
<RowStyle VerticalAlign="Top" />
HeaderText="ÍÐÝ">
<ItemTemplate>
<asp:ImageButton ID="btn_Delete_Task" runat="server"
CommandArgument="<%# Bind('task_code') %>" Height="33px"
ImageUrl="~/Images/delete.png" oncommand="btn_Delete_Task_Command"
Width="67px" />
<cc1:ConfirmButtonExtender ID="btn_Delete_Task_ConfirmButtonExtender"
runat="server" ConfirmText="åá ÊÑíÏ ÍÐÝ æËíÞÉ ÇáÇÚÊãÇÏ ¿" Enabled="True"
TargetControlID="btn_Delete_Task">
</cc1:ConfirmButtonExtender>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle HorizontalAlign="Right" />
</asp:GridView>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right" dir="rtl">
<asp:Label ID="lbl_TaskName" runat="server" Font-Bold="True" Font-Size="13pt"></asp:Label>
</td>
</tr>
<tr>
<td align="center" dir="rtl" style="height: 196px">
<table>
<tr>
<td align="left">
<asp:Label ID="lbl_No_States" runat="server" Font-Bold="True" ForeColor="Red"></asp:Label>
</td>
<td align="right">
<asp:ImageButton ID="btn_AddStatesToTask" runat="server"
ImageUrl="Images/add.png" onclick="btn_AddStatesToTask_Click" Visible="False" />
<asp:Button ID="Dummy_btn2" runat="server" Text="Button" Style="display:none;" />
<cc1:ModalPopupExtender ID="btn_AddStatesToTask_ModalPopupExtender"
runat="server"
TargetControlID="Dummy_btn2"
BackgroundCssClass="modalBackground"
PopupControlID="pnl_Add_States"
DropShadow="True">
</cc1:ModalPopupExtender>
</td>
</tr>
</table>
<asp:HiddenField ID="hd_StateSerial" runat="server" />
<asp:HiddenField ID="hd_StateRowIndex" runat="server" />
<asp:GridView ID="grd_States" runat="server" AllowPaging="True" DataKeyNames="state_serial"
onpageindexchanging="grd_States_PageIndexChanging" Visible="False"
CssClass="Alternating" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="state_name" HeaderText="ÇáãÑÍáÉ"
ShowHeader="False" />
<asp:BoundField DataField="state_order" HeaderText="ÊÑÊíÈ ÇáãÑÍáÉ"
ShowHeader="False" />
<asp:TemplateField HeaderText="Power" ShowHeader="False">
<EditItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="chb_StatePower" runat="server"
Checked='<%# Convert.ToBoolean(Eval("power_flag")) %>' Enabled="False" />
</ItemTemplate>
<ItemStyle Width="40px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="New" ShowHeader="False">
<EditItemTemplate>
<asp:CheckBox ID="CheckBox3" runat="server" />
<asp:Button ID="Dummy_btn4" runat="server" Text="Button" Style="display:none;" />
<cc1:ModalPopupExtender ID="btn_TaskState_Edit_ModalPopupExtender" runat="server"
TargetControlID="Dummy_btn4"
BackgroundCssClass="modalBackground"
PopupControlID="pnl_Add_States"
DropShadow="True">
</cc1:ModalPopupExtender>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ÍÐÝ" ShowHeader="False">
<ItemTemplate>
<asp:ImageButton ID="btn_TaskState_Delete" runat="server"
CommandArgument="<%# Bind('state_serial') %>" Height="26px"
ImageUrl="~/Images/delete.png" oncommand="btn_TaskState_Delete_Command"
Width="47px" />
<cc1:ConfirmButtonExtender ID="btn_TaskState_Delete_ConfirmButtonExtender"
runat="server" ConfirmText="åá ÊÑíÏ ÍÐÝ ÇáãÑÍáÉ ¿" Enabled="True"
TargetControlID="btn_TaskState_Delete">
</cc1:ConfirmButtonExtender>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
<tr>
<td>
<asp:ObjectDataSource ID="ObjectDataSource_States" runat="server"
SelectMethod="Select_TaskStates" TypeName="DocumentFlowModule.DTO.TaskStateDTO">
<SelectParameters>
<asp:Parameter Name="task_code" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</td>
</tr>
</table>
</div>
</div>
</asp:Panel>
<asp:Panel ID="pnl_Add_Task" runat="server" CssClass="modalPopup"><%-- Style="display:none;"--%>
<div id="div3" style="width: 95%">
<div id="div4" align="center">
<table>
<tr>
<td>
<asp:UpdatePanel ID="UpPnl1" runat="server">
<ContentTemplate>
<table dir="rtl" style="text-align: right">
<tr bgcolor="#f1ece2">
<th align="right" height="35" valign="middle" colspan="3">
<asp:Label ID="lbl_New_Task" runat="server" Font-Bold="False" Font-Size="14pt"
Text="ÅÖÇÝÉ æËíÞÉ ÇÚÊãÇÏ" Visible="False"></asp:Label>
<asp:Label ID="lbl_Edit_Task" runat="server" Font-Bold="False" Font-Size="14pt"
Text="ÊÚÏíá æËíÞÉ ÇÚÊãÇÏ" Visible="False"></asp:Label>
</th>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label1" runat="server" Text="Task Name"></asp:Label>
</td>
<td style="width: 140px">
<asp:TextBox ID="txt_TaskName" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txt_TaskName" ErrorMessage="*" ValidationGroup="G1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label10" runat="server" Text="DataBase Name"></asp:Label>
</td>
<td style="width: 140px">
<asp:DropDownList ID="ddl_DataBases" runat="server" AutoPostBack="True"
ondatabound="ddl_DataBases_DataBound"
onselectedindexchanged="ddl_DataBases_SelectedIndexChanged">
</asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="ddl_DataBases" ErrorMessage="*" InitialValue="--Select--"
ValidationGroup="G1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label2" runat="server" Text="Table Name"></asp:Label>
</td>
<td style="width: 140px">
<asp:DropDownList ID="ddl_Tables" runat="server" AutoPostBack="True"
ondatabound="ddl_Tables_DataBound"
onselectedindexchanged="ddl_Tables_SelectedIndexChanged">
</asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="ddl_Tables" ErrorMessage="*" InitialValue="--Select--"
ValidationGroup="G1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label17" runat="server" Text="Table Key"></asp:Label>
</td>
<td style="width: 140px">
<asp:Label ID="lbl_Key" runat="server"></asp:Label>
<asp:CheckBoxList ID="cbl_Columns" runat="server">
</asp:CheckBoxList>
</td>
<td>
<asp:Label ID="lbl_Select_Key" runat="server" ForeColor="Red"></asp:Label>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label18" runat="server" Text="Current Record State"></asp:Label>
</td>
<td style="width: 140px">
<asp:DropDownList ID="ddl_Columns" runat="server" AutoPostBack="True"
ondatabound="ddl_Columns_DataBound">
</asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="ddl_Columns" ErrorMessage="*" InitialValue="--Select--"
ValidationGroup="G1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label5" runat="server" Text="Form View "></asp:Label>
</td>
<td style="width: 140px">
<asp:TextBox ID="txt_F_View" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ControlToValidate="txt_F_View" ErrorMessage="*" InitialValue="--Select--"
ValidationGroup="G1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label6" runat="server" Text="Form New"></asp:Label>
</td>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td dir="rtl" align="center">
<asp:ImageButton ID="btn_OK" runat="server" ImageUrl="~/Images/add.png"
onclick="btn_OK_Click" ValidationGroup="G1" Visible="False" />
<asp:ImageButton ID="btn_Edit" runat="server" ImageUrl="~/Images/edit.png"
onclick="btn_Edit_Click" ValidationGroup="G1" Visible="False" />
<asp:ImageButton ID="btn_Cancel_Task" runat="server" CausesValidation="False"
Height="36px" ImageUrl="~/Images/cancel.png" onclick="btn_Cancel_Task_Click" />
</td>
</tr>
</table>
</div>
</div>
</asp:Panel>
the btn_add _task does not make my popup appear just freeze the parent page
my .cs
protected void btn_Add_Task_Click(object sender, EventArgs e)
{
//AjaxControlToolkit.ModalPopupExtender modal1 = (AjaxControlToolkit.ModalPopupExtender) table1.FindControl("btn_Add_Task_ModalPopupExtender");
//modal1.Show();
grd_States.Visible = false;
lbl_No_States.Text = "";
btn_AddStatesToTask.Visible = false;
lbl_TaskName.Text = "";
//master_editMode.Visible = true;
//pnl_Add_Task.Visible = true;
btn_OK.Visible = true;
btn_Edit.Visible = false;
lbl_New_Task.Visible = true;
lbl_Edit_Task.Visible = false;
txt_TaskName.Text = "";
ddl_DataBases.ClearSelection();
ddl_Tables.Items.Clear();
ddl_Columns.Items.Clear();
cbl_Columns.Items.Clear();
txt_F_New.Text = "";
txt_F_View.Text = "";
txt_Params.Text = "";
txt_SP_Name.Text = "";
btn_Add_Task_ModalPopupExtender.Show();
}
thanks in advance
EDITED::
<table align="center" dir="rtl">
<tr>
<td >
<asp:Button ID="Dummy_btn" runat="server" Text="Button" Style="display:none;" />
<asp:Button ID="btn_Add_Task" runat="server" Text="ÅÖÇÝÉ æËíÞÉ ÇÚÊãÇÏ ÌÏíÏÉ"
onclick="btn_Add_Task_Click" Font-Bold="True" Font-Size="12pt"
ForeColor="#0066FF" />
<cc1:ModalPopupExtender ID="btn_Add_Task_ModalPopupExtender" runat="server"
TargetControlID="Dummy_btn"
PopupControlID="pnl_Add_Task"
BackgroundCssClass="modalBackground"
DropShadow="True" >
</cc1:ModalPopupExtender>
</td>
</tr>
</table>`
If you want your modal popup to be displayed when the user clicks on the btn_Add_Task button, you should set that button as the TargetControlID of the extender:
<cc1:ModalPopupExtender ID="btn_Add_Task_ModalPopupExtender" runat="server"
TargetControlID="btn_Add_Task" PopupControlID="pnl_Add_Task"
BackgroundCssClass="modalBackground" DropShadow="True" />
In your current code, the modal popup is triggered by a button named Dummy_btn, which I can't find in your markup, but which probably isn't what you want.
We had many issues with ajax popup. you might want to try the approach we have been using for past one month or so with out any issues. This approach creates a popup with out need of ajax / jquery / javascript /css/ update panel .
here:
A modal popup with out using ajax, update panel, jquery or javascript- surprisingly this seems to work