how to pop up two modalpopup in gridview - c#

I want to pop up two modalpopup from a gridview. I searched online but couldn't find the exact answer. Any help is appreciated.
--------ModalPopupExtender1---------
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
BackgroundCssClass="ModalPopupBG" CancelControlID="btn_Cancel" Drag="true"
PopupControlID="Panel2" PopupDragHandleControlID="Panel2"
TargetControlID="btnNew">
</asp:ModalPopupExtender>
-----------------PopupControlID="Panel2--------------------------
<div id="Panel2" class="popupConfirmation">
<div class="popup_Container">
<div id="PopupHeader" class="popup_Titlebar">
<div class="TitlebarLeft">
<%--
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
--%>
Edit Customer
</div>
<!--
<div class="TitlebarRight" >
</div>
-->
</div>
<div>
<table bgcolor="#CCFFFF" cellpadding="0" cellspacing="2" width="100%">
<tr>
<td width="5%">
</td>
<td width="25%">
</td>
<td width="65%">
</td>
<td width="5%">
</td>
</tr>
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="25%">
<asp:LabelID="lblName"runat="server"FontSize="11pt" Text="First Name:">
</asp:Label>
</td>
<td style="text-align: left" width="65%">
<asp:TextBox ID="txtFirstName" runat="server" Width="300px">
</asp:TextBox>
<asp:Label ID="lbl_ErrorName" runat="server" ForeColor="Red"
style="display:none" Text="*">
</asp:Label>
</td>
<td width="5%">
</td>
</tr>
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="25%">
<asp:Label ID="lblName2" runat="server" Font-Size="11pt" Text="Second Name:">
</asp:Label>
</td>
<td style="text-align: left" width="65%">
<asp:TextBox ID="txtSecondName" runat="server" Width="300px">
</asp:TextBox>
</td>
<td width="5%">
</td>
</tr>
<%--
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="45%">
<asp:Label ID="lblName0" runat="server" Font-Size="11pt" Text="City">
</asp:Label>
</td>
<td style="text-align: left" width="45%">
<asp:TextBox ID="txtCity" runat="server" Width="200px">
</asp:TextBox>
</td>
<td width="5%">
</td>
<td width="5%">
</td>
</tr>
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="45%">
<asp:Label ID="lblName1" runat="server" Font-Size="11pt" Text="State">
</asp:Label>
</td>
<td style="text-align: left" width="45%">
<asp:TextBox ID="txtState" runat="server" Width="200px">
</asp:TextBox>
</td>
<td width="5%">
</td>
<td width="5%">
</td>
</tr>
--%>
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="25%">
<asp:Label ID="lblAddress1" runat="server" Font-Size="11pt" Text="Address1:">
</asp:Label>
</td>
<td style="text-align: left" width="65%">
<asp:TextBox ID="txtAddress1" runat="server" Width="300px">
</asp:TextBox>
<asp:Label ID="lbl_ErrorAddress1" runat="server" ForeColor="Red"
style="display:none" Text="*">
</asp:Label>
</td>
<td width="5%">
</td>
</tr>
<%--
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="45%">
<asp:Label ID="lblAddress2" runat="server" Font-Size="11pt" Text="Address2:">
</asp:Label>
</td>
<td style="text-align: left" width="45%">
<asp:TextBox ID="txtAddress2" runat="server" Width="200px">
</asp:TextBox>
</td>
<td width="5%">
</td>
<td width="5%">
</td>
</tr>
--%>
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="25%">
<asp:Label ID="lblDOB" runat="server" Font-Size="11pt" Text="Phone">
</asp:Label>
</td>
<td style="text-align: left" width="65%">
<asp:TextBox ID="txtPhone" runat="server" Width="200px">
</asp:TextBox>
<%--
<asp:CalendarExtender ID="txt_DOB_CalendarExtender" runat="server"
TargetControlID="txt_DOB">
</asp:CalendarExtender>
--%>
<asp:Label ID="lblErrorDOB" runat="server" Font-Bold="True" ForeColor="Red"
style="display:none" Text="*">
</asp:Label>
</td>
<td width="5%">
</td>
</tr>
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="25%">
<asp:Label ID="lblDOB0" runat="server" Font-Size="11pt" Text="Mobile">
</asp:Label>
</td>
<td style="text-align: left" width="65%">
<asp:TextBox ID="txtMobile" runat="server" Width="200px">
</asp:TextBox>
</td>
<td width="5%">
</td>
</tr>
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="25%">
</td>
<td style="text-align: left" width="65%">
</td>
<td width="5%">
</td>
</tr>
</table>
</div>
<div align="center">
<asp:Button ID="btn_Update" runat="server"
Text="Save" Width="75px" onclick="btn_Update_Click" />
<asp:Button ID="btn_Cancel" runat="server" Text="Cancel" Width="75px" />
</div>
</div>
</div>
----------------`ModalpopUp`----------------------------
<asp:ModalPopupExtender ID="ModalPopUp" runat="server"
CancelControlID="idclose" Drag="true" DynamicServicePath="" Enabled="True"
PopupControlID="PartyCustomers_idbody"
PopupDragHandleControlID="PartyCustomers_IdTitle"
TargetControlID="btnShowPopup">
<Animations>
<OnShown><Fadein Duration="0.50" /></OnShown>
<OnHiding><Fadeout Duration="0.75" /></OnHiding>
</Animations>
</asp:ModalPopupExtender>
--------------------PartyCustomers_idbody : popupbody--------------
`<div id="PartyCustomers_idbody" runat="server" class="Common_divbody"
>
<div id="PartyCustomers_IdTitle" runat="server" class="Common_divtitle"
>
<div id="idclose" class="Common_close">
</div>
<div class="Common_divhr">
Booked Status</div>
</div>
<div class="ModalPopUpDiv">
<asp:Label ID="lblmessage1" runat="server" Text="Label"></asp:Label>
<asp:GridView ID="dgvSystemDetails" runat="server" AllowPaging="True"
AllowSorting="True" AlternatingRowStyle-CssClass="alt"
AutoGenerateColumns="False" CellSpacing="2" CssClass="mGrid" Font-Bold="True"
Font-Names="Arial" Font-Size="Small" PageSize="12"
Width="750px" DataKeyNames="SystemCode"
onrowdatabound="dgvSystemDetails_RowDataBound">
<AlternatingRowStyle CssClass="alt" />
<Columns>
<asp:BoundField DataField="RegistrationDate" DataFormatString="{0:d}"
HeaderText="Registration Date">
<HeaderStyle />
<ItemStyle />
</asp:BoundField>
<asp:BoundField DataField="SystemCode" HeaderText="System Code" />
<asp:BoundField DataField="Reg_Status" HeaderText="Reg. Status" />
<asp:BoundField DataField="Key" HeaderText="Key" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnBlock" runat="server" CssClass="Common_button"
Text="Block" onclick="btnBlock_Click" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>`
--------------------------------cs-: RowCommand---code--------------------------
protected void dgvActivatedCustomers_RowCommand1(object sender, GridViewCommandEventArgs e)
{
//Load System details gridview in modalpop up...
if(e.CommandName=="Select")
{
DataSet ds;
int RowIndex = Convert.ToInt32(e.CommandArgument);
long ProductSerialID = Convert.ToInt32(dgvActivatedCustomers.DataKeys[RowIndex].Values["ProductSerialID"]) ;
hdnProuductId.Value= dgvActivatedCustomers.DataKeys[RowIndex].Values["ProductSerialID"].ToString();
lblmessage1.Visible = true;
//string RegStatus = dgvSystemDetails.SelectedRow.Cells[2].Text;
string ProductSerial = dgvActivatedCustomers.Rows[RowIndex].Cells[6].Text;
string Reg_Status = LoadSystemDetails(ProductSerialID).Tables[0].Rows[0]["Reg_Status"].ToString();
lblmessage1.Text = "Activation Code :" + General.GetActivationCode(Convert.ToDouble(ProductSerial)).ToString();
LoadSystemDetails(ProductSerialID);
ds = LoadSystemDetails(ProductSerialID);
//filling data table
DataTable dt = (DataTable)dgvSystemDetails.DataSource;
//Add new columns to datatable
dt.Columns.Add("Key", typeof(System.Int64));
// get key for specific key by passing system code ot getRegistrationKey.
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string SystemCode = ds.Tables[0].Rows[i]["SystemCode"].ToString();
//lblmessage2.Text = "Key :" + Registration.getRegistrationKey(SystemCode, ProductSerial);
string Key = Registration.getRegistrationKey(SystemCode, ProductSerial);
dt.Rows[i]["Key"] = Key;
}
Session["dgvSystemDetailsDataSource"] = dt;
dgvSystemDetails.DataSource = dt;
dgvSystemDetails.DataBind();
dgvSystemDetails.Visible = true;
if (Reg_Status == "Blocked")
{
lblmessage1.Visible = true;
lblmessage1.Text = "Blocked System";
//dgvSystemDetails.FindControl("btnBlock").Visible = false;
dgvSystemDetails.DataSource = Session["dgvSystemDetailsDataSource"];
dgvSystemDetails.DataBind();
ModalPopUp.Show();
}
ModalPopUp.Show();
}
}
description :btnclick second popup--------------
protected void Button1_Click(object sender, EventArgs e)
{
try
{
Button btn = (Button)sender;
GridViewRow row = (GridViewRow)btn.NamingContainer;
int rowno = row.RowIndex;
txtFirstName.Text = dgvActivatedCustomers.DataKeys[rowno].Values["CustomerName"].ToString();
txtSecondName.Text = dgvActivatedCustomers.DataKeys[rowno].Values["CustomerLName"].ToString();
txtAddress1.Text = (dgvActivatedCustomers.Rows[rowno].Cells[4].Text != " " ? dgvActivatedCustomers.Rows[rowno].Cells[4].Text : "");
txtPhone.Text = (dgvActivatedCustomers.Rows[rowno].Cells[2].Text != " " ? dgvActivatedCustomers.Rows[rowno].Cells[2].Text : "");
txtMobile.Text = (dgvActivatedCustomers.Rows[rowno].Cells[3].Text != " " ? dgvActivatedCustomers.Rows[rowno].Cells[3].Text : "");
hdnId.Value = dgvActivatedCustomers.DataKeys[rowno].Values["CustomerID"].ToString();
txtName.Text = (dgvDemoCust.SelectedRow != "") ? dgvDemoCust.SelectedRow.Cells[0].Text : "";
ModalPopupExtender1.Show();
}
catch (Exception ex) { }
}
Question : The first pop up is showing but the second one doesn't.....any body have any idea

Related

Decimal point in "Convert.ToInt" statement causing Format Error?

I have been following this tutorial to help me create a basic shopping basket. When trying to run the code with the below method added which should calculate the TotalPrice & TotalProducts of the basket on the OrderForm, I get the following error:
'System.FormatException' occurred in mscorlib.dll but was not handled in user code. Additional information: Input string was not in a correct format.
pointing at the line
long ProductPrice =
Convert.ToInt64(PriceLabel.Text) *
Convert.ToInt64(ProductQuantity.Text);
In the database, an example of a ProductPrice is "199.99" where as the tutorial only used whole numbers e.g. "199". I am not sure if this is what is causing the issue? If this is the case, how should the code below be modified to include the decimal point too?
I am new to coding, so this is really stressing me out, I really would appreciated some guideance/suggested code changes to overcome this issue
Thanks as ever guys!
private void UpdateTotalBill()
{
long TotalPrice = 0;
long TotalProducts = 0;
foreach (DataListItem item in dlBasketItems.Items)
{
//Finds the price label on pnlMyBasket
Label PriceLabel = item.FindControl("lblPrice") as Label;
//Finds the quantity text box on pnlMyBasket
TextBox ProductQuantity = item.FindControl("txtProductQuantity") as TextBox;
long ProductPrice = Convert.ToInt32(PriceLabel.Text) * Convert.ToInt32(ProductQuantity.Text);
TotalPrice = TotalPrice + ProductPrice;
TotalProducts = TotalProducts + Convert.ToInt32(ProductQuantity.Text);
}
txtTotalPrice.Text = Convert.ToString(TotalPrice);
txtTotalProducts.Text = Convert.ToString(TotalProducts);
}
pnlMyBasket
<asp:Panel ID="pnlMyBasket" runat="server" ScrollBars="Auto" Height="500px" BorderColor="Black" BorderStyle="Inset" BorderWidth="1px" Visible="false">
<table align="center" cellspacing="1">
<tr>
<td align="center" class="auto-style4">
<asp:Label ID="lblAvailableStockAlert" runat="server" ForeColor="Red" Font-Bold="true"></asp:Label>
<asp:DataList ID="dlBasketItems" runat="server" RepeatColumns="3" Font-Bold="False"
Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False"
Width="551px">
<ItemTemplate>
<div align="left">
<table cellspacing="1" style="border: 1px ridge #9900FF; text-align: center; width: 172px;">
<tr>
<td style="border-bottom-style: ridge; border-width: 1px; border-color: #000000">
<asp:Label ID="lblProductName" runat="server" Text='<%# Eval("ProductName")%>' Style="font-weight: 700"></asp:Label>
</td>
</tr>
<tr>
<td>
<img alt="" src='<%# Eval("ProductImageUrl") %>' runat="server" id="imgProductPhoto" style="border: ridge 1px black;
width: 157px; height: 130px;" />
</td>
</tr>
<tr>
<td>AvailableStock: <asp:Label ID="lblAvailableStock" runat="server" Text='<%# Eval("ProductStock") %>'
ToolTip="Available Stock" ForeColor="Red" Font-Bold="true"></asp:Label>
<br />
Price:<asp:Label ID="lblPrice" runat="server" Text='<%# Eval ("ProductPrice") %>'></asp:Label>
<br /> Quantity Required x
<asp:TextBox ID="txtProductQuantity" runat="server" Width="20px" Height="10px" MaxLength="2" OnTextChanged="txtProductQuantity_TextChanged" AutoPostBack="true" ></asp:TextBox>
<asp:HiddenField ID="hfProductID" runat="server" Value='<%# Eval("ProductID") %>' />
</td>
</tr>
<tr>
<td>
<hr /> <asp:Button ID="btnRemoveFromBasket" runat="server" CommandArgument='<%# Eval("ProductID") %>'
Text="Remove From Basket" Width="100%" BorderColor="Black" BorderStyle="Inset" BorderWidth="1px"
OnClick="btnRemoveFromBasket_Click" CausesValidation="false" />
</td>
</tr>
</table>
</div>
</ItemTemplate>
<ItemStyle Width="33%" />
</asp:DataList>
</td>
</tr>
</table>
</asp:Panel>
pnlOrderForm
<asp:Panel ID="pnlOrderForm" runat="server" ScrollBars="Auto" Height="500px" BorderColor="Black"
BorderStyle="Inset" BorderWidth="1px" Visible="false">
<table style="width: 258px;">
<tr>
<td align="left">
Name:
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="txtCustomerName" runat="server" Width="231px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtCustomerName"
ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="left">
PhoneNo:
</td>
</tr
<tr>
<td>
<asp:TextBox ID="txtCustomerPhoneNo" runat="server" Width="231px" MaxLength="10"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtCustomerPhoneNo"
ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="left">
EmailID
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="txtCustomerEmailID" runat="server" Width="231px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtCustomerEmailID"
ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="left">
Address
</td>
</tr>
<tr>
<td align="left">
<asp:TextBox ID="txtCustomerAddress" runat="server" Width="227px" Height="81px"
TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtCustomerAddress"
ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="left">
Total Products :
</td>
</tr>
<tr>
<td align="center">
<asp:TextBox ID="txtTotalProducts" runat="server" ReadOnly="True" Width="231px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtTotalProducts"
ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="left">
Total Price :
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="txtTotalPrice" runat="server" ReadOnly="True" Width="231px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtTotalPrice"
ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="left">
Payment Mode:
</td>
</tr>
<tr>
<td align="left">
<asp:RadioButtonList ID="rblMethodOfPayment" runat="server">
<asp:ListItem Value="1" Selected="True">1. Collect & Pay In Store</asp:ListItem>
<asp:ListItem Value="2">2. Pay with card</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td>
<br />
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnPlaceOrder" runat="server" OnClick="btnPlaceOrder_Click" Style="font-weight: 700"
Text="PlaceOrder" Width="90px" />
</td>
</tr>
<tr>
<td>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtCustomerEmailID"
ErrorMessage="Please Enter Valid EmailId" ForeColor="Red" ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
</table>
</asp:Panel>
I think you need to convert to decimal, then to long. Like this:
long ProductPrice;
try
{
// hey you never know, someone might just put in an int64 in that textbox!
ProductPrice = Convert.ToInt32(PriceLabel.Text) *
Convert.ToInt32(ProductQuantity.Text);
}
catch
{
decimal tempPrice = Convert.ToDecimal(PriceLabel.Text) *
Convert.ToDecimal(ProductQuantity.Text);
ProductPrice = Convert.ToInt64(tempPrice);
}
Most direct way to how you are currently doing:
var ProductPrice = Convert.ToDecimal(PriceLabel.Text) * Convert.ToDecimal(ProductQuantity.Text);
this will throw an exception if the value cannot be converted to a decimal. Decimal.TryParse() would be better.
https://msdn.microsoft.com/en-us/library/system.decimal.tryparse(v=vs.110).aspx

ASP:Login : Password not autocomplete after enter Username

I used ASP:Login to take a Login form for my page.
Now I have 2 problem and I try to find a solution but ... #_#.
Now, I enter to login page. Type user, type password, then Enter
Problem 1 : Enter key not focus to Login button. It's mean, I must click to Login button to login. How can to set default button in this case ?
Problem 2 : Ok. Logged in. The browser (Chrome, Firefox ...) ask to save password. Ok. Saved.
And then, when I enter to login page in another time. The password will not autofill when I enter the username (browser still save username and password info).
Did I take a mistake in my setting or my code ? :(
My code :
<asp:Login ID="Login1" runat="server" BackColor="transparent" Font-Names="Verdana"
Font-Size="0.8em" ForeColor="#333333" Height="147px"
LoginButtonText="Đăng nhập" onloggingin="Login1_LoggingIn"
RememberMeText="Nhớ password cho lần đăng nhập sau."
TitleText="Đăng nhập hệ thống" Width="400px"
FailureText="Đăng nhập không thành công!"
HelpPageText="Anh, chị là khách hàng? "
onauthenticate="Login1_Authenticate"
PasswordRequiredErrorMessage="Chưa nhập Password."
UserNameRequiredErrorMessage="Chưa nhập User Name." BorderColor="#339933"
BorderStyle="Solid" BorderWidth="1px" CssClass="border">
<HyperLinkStyle Font-Size="10pt" HorizontalAlign="Left" />
<InstructionTextStyle Font-Italic="True" ForeColor="Black" />
<LabelStyle Wrap="True" />
<LayoutTemplate>
<table cellpadding="4" cellspacing="0" style="border-collapse:collapse;">
<tr>
<td>
<table cellpadding="0" style="height:147px;width:400px;">
<tr>
<td align="left" colspan="2"
style="color:White;background-color:#006D55;font-size:11pt;font-weight:bold;height:25px;white-space:nowrap; padding-left: 10px;">
Đăng nhập hệ thống</td>
</tr>
<tr>
<td align="left" colspan="2">
<br>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
</td>
<td align="left">
<asp:TextBox ID="UserName" runat="server" Font-Size="10pt" Height="22px"
Width="250px" CssClass="border"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server"
ControlToValidate="UserName" ErrorMessage="Chưa nhập User Name."
ToolTip="Chưa nhập User Name." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
</td>
<td align="left">
<asp:TextBox ID="Password" runat="server" Font-Size="10pt" Height="22px"
TextMode="Password" Width="250px" CssClass="border" Wrap="False"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server"
ControlToValidate="Password" ErrorMessage="Chưa nhập Password."
ToolTip="Chưa nhập Password." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="left" colspan="2">
<br />
</td>
</tr>
<tr>
<td colspan="2">
<asp:CheckBox ID="RememberMe" runat="server"
Text="Nhớ password cho lần đăng nhập sau." AutoPostBack="True" />
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color:Red;">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="LoginButton" runat="server" BackColor="#006D55"
BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" CommandName="Login"
Font-Names="Verdana" Font-Size="11pt" ForeColor="White" Height="25px"
Text="Login" ValidationGroup="Login1" Width="100%" />
</td>
</tr>
<tr>
<td align="left" colspan="2">
<hr />
</td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:HyperLink ID="HelpLink" runat="server" Font-Size="10pt">Anh, chị chưa có tài khoản ? </asp:HyperLink>
</td>
</tr>
<tr align="center">
<td align="left" colspan="2" style="padding-top: 10px;">
<dx:ASPxButton ID="ASPxButton1" runat="server" Text="Tạo tài khoản"
onclick="ASPxButton1_Click" Width="100%"
Font-Size="11pt" Font-Names="Verdana" BackColor="White"
ForeColor="#006D55" Height="20px" HorizontalAlign="Center">
<HoverStyle BackColor="#A6DDD1" Font-Bold="True">
</HoverStyle>
<Border BorderColor="#006D55" />
</dx:ASPxButton>
</td>
</tr>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
<LoginButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
BorderWidth="1px" Font-Names="Verdana" Font-Size="10pt" ForeColor="#284775"
Height="25px" Width="80px" />
<TextBoxStyle Font-Size="10pt" Height="22px" Width="150px" />
<TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" Font-Size="10pt"
ForeColor="White" Height="25px" HorizontalAlign="Left" Wrap="False" />
sp_compa.Service1 ws = new sp_compa.Service1();
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack) return;
Session["STATION_CODE"] = "";
Session["COMP_CODE"] = "";
Session["COMP_NAME"] = "";
Session["UserName"] = "";
Session["PassWord"] = "";
Session.Timeout = 120;
}
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
string user = this.Login1.UserName.Trim();
string password = this.Login1.Password.Trim();
DataSet ds = sp.get_user_new(user, clsdb.identity);
Session["dsuser"] = ds;
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
DataRow row = ds.Tables[0].Rows[0];
if (this.Login1.Password.ToUpper().Trim().Equals(row["PassWord"].ToString().ToUpper()))
{
e.Authenticated = true;
Session["UserName"] = user;
Session["PassWord"] = password;
Session["COMP_CODE_User"] = row["COMP_CODE"];
if ((bool)row["KH"] == false)
Response.Redirect("~/Home.aspx");
else
{
Response.Redirect("~/ttkh.aspx");
}
}
else
{
}
}
e.Authenticated = false;
}
Solution for Problem 1 is to use Asp.Net panel and use it's Defauenter code hereltButton property.
For example,
<asp:Login ID="Login1" runat="server">
<LayoutTemplate>
<asp:Panel ID="Panel1" runat="server" DefaultButton = "LoginButton">
<table cellpadding="4" cellspacing="0" style="border-collapse:collapse;">
<tr>
<td>
<table cellpadding="0" style="height:147px;width:400px;">
<tr>
<td align="left" colspan="2"
style="color:White;background-color:#006D55;font-size:11pt;font-weight:bold;height:25px;white-space:nowrap; padding-left: 10px;">
Đăng nhập hệ thống</td>
</tr>
<tr>
<td align="left" colspan="2">
<br>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
</td>
<td align="left">
<asp:TextBox ID="UserName" runat="server" Font-Size="10pt" Height="22px"
Width="250px" CssClass="border"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server"
ControlToValidate="UserName" ErrorMessage="Chưa nhập User Name."
ToolTip="Chưa nhập User Name." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
</td>
<td align="left">
<asp:TextBox ID="Password" runat="server" Font-Size="10pt" Height="22px"
TextMode="Password" Width="250px" CssClass="border" Wrap="False"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server"
ControlToValidate="Password" ErrorMessage="Chưa nhập Password."
ToolTip="Chưa nhập Password." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="left" colspan="2">
<br />
</td>
</tr>
<tr>
<td colspan="2">
<asp:CheckBox ID="RememberMe" runat="server"
Text="Nhớ password cho lần đăng nhập sau." AutoPostBack="True" />
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color:Red;">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="LoginButton" runat="server" BackColor="#006D55"
BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" CommandName="Login"
Font-Names="Verdana" Font-Size="11pt" ForeColor="White" Height="25px"
Text="Login" ValidationGroup="Login1" Width="100%" />
</td>
</tr>
<tr>
<td align="left" colspan="2">
<hr />
</td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:HyperLink ID="HelpLink" runat="server" Font-Size="10pt">Anh, chị chưa có tài khoản ? </asp:HyperLink>
</td>
</tr>
<tr align="center">
<td align="left" colspan="2" style="padding-top: 10px;">
<dx:ASPxButton ID="ASPxButton1" runat="server" Text="Tạo tài khoản"
onclick="ASPxButton1_Click" Width="100%"
Font-Size="11pt" Font-Names="Verdana" BackColor="White"
ForeColor="#006D55" Height="20px" HorizontalAlign="Center">
<HoverStyle BackColor="#A6DDD1" Font-Bold="True">
</HoverStyle>
<Border BorderColor="#006D55" />
</dx:ASPxButton>
</td>
</tr>
</table>
</td>
</tr>
</table>
</asp:Panel>
</LayoutTemplate>
</asp:Login>
In regards to problem 2, I do not know why your browser is not pushing password back to the text box.

Calling user control within a user control

Hi I have two usercontrols.
The first user control has a button and the second user control has a popup control.
I registered the second user control in the first user control with id=ctlPopUp
Onclick event of button I have to display the popup control.
I tried with
protected void btnUser_Click(object sender, EventArgs e)
{
var userCtlPopup = ctlPopUp.FindControl("pcDownload");
userCtlPopup.Visible = true;
}
It doesn't work. Can you please suggest?
Hi here is the user control markups:
POpupUsercontrol:
<div id="divDownload" runat="server" visible="true">
<dx:aspxpopupcontrol id="pcDownload" runat="server" showpagescrollbarwhenmodal="true"
clientinstancename="pcDownload" enableclientsideapi="true" modal="True" popuphorizontalalign="WindowCenter"
popupverticalalign="WindowCenter" showheader="false" allowdragging="True" enableanimation="False"
enableviewstate="False" width="600px" autoupdateposition="true" closeaction="CloseButton">
<ContentCollection>
<dx:PopupControlContentControl ID="PopupControlContentControl4" runat="server"
Width="100%">
<dx:ASPxPanel ID="ASPxPanel3" runat="server">
<PanelCollection>
<dx:PanelContent ID="PanelContent4" runat="server">
<div>
<table class="cChildTable">
<tr>
<td>
<h3>Download</h3>
</td>
</tr>
<tr>
<td class="auto-style1">
<div class="hr">
</div>
<asp:Label ID="lblDownLoadMessages" runat="server" CssClass="cMessageArea"></asp:Label>
</td>
</tr>
</table>
<table class="cChildTable" border="0">
<tr><td style="font:bold" colspan="2"><asp:Label ID="Title" runat="server" Text="Content Link Title"></asp:Label></td></tr>
<tr>
<td style="vertical-align: top; width: 30px; padding: 2px" rowspan="8">
<asp:CheckBox ID="chkImg" runat="server" AutoPostBack="True" Checked="true" />
</td>
<td style="vertical-align: top" rowspan="3">
<asp:Image runat="server" ID="imgUpload" Width="100px" Height="100px" Style="top: 0px;" AlternateText="No Image" />
</td>
<td>
<asp:CheckBox ID="chkName" runat="server"
AutoPostBack="true" />
</td>
<td class="cLabel" style="width: 15%">
<asp:Label ID="lblName" runat="server" Text="Name:" Width="90px"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtName" runat="server" CssClass="cText" Width="300px" MaxLength="75"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:CheckBox ID="chkCompany" runat="server"
AutoPostBack="true" />
</td>
<td class="cLabel" style="width: 15%">
<asp:Label ID="lblCompany" runat="server" Text="Company:" Width="90px"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtCompany" runat="server" CssClass="cText" Width="300px" MaxLength="75"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:CheckBox ID="chkAddress" runat="server"
AutoPostBack="true" />
</td>
<td class="cLabel" style="width: 15%">
<asp:Label ID="lblAddress" runat="server" Text="Address:" Width="90px"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtAddress" runat="server" CssClass="cText" Width="300px" MaxLength="75"></asp:TextBox>
</td>
</tr>
<tr>
<td rowspan="5" style="vertical-align:top"><asp:LinkButton ID="lnkAddImg" runat="server"> </asp:LinkButton></td>
<td>
<asp:CheckBox ID="chkCtyStateZip" runat="server"
AutoPostBack="true" />
</td>
<td class="cLabel" style="width: 15%">
<asp:Label ID="lblCtyStateZip" runat="server" Text="City, State Zip:" Width="90px"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtCtyStateZip" runat="server" CssClass="cText" Width="300px" MaxLength="75"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:CheckBox ID="chkPhone" runat="server"
AutoPostBack="true" />
</td>
<td class="cLabel" style="width: 15%">
<asp:Label ID="lblPhone" runat="server" Text="Phone:" Width="90px"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtPhone" runat="server" CssClass="cText" Width="150px" MaxLength="75"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:CheckBox ID="chkFax" runat="server"
AutoPostBack="true" />
</td>
<td class="cLabel" style="width: 15%">
<asp:Label ID="lblFax" runat="server" Text="Fax:" Width="90px"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtFax" runat="server" CssClass="cText" Width="150px" MaxLength="75"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:CheckBox ID="chkEmail" runat="server"
AutoPostBack="true" />
</td>
<td class="cLabel" style="width: 15%">
<asp:Label ID="lblEmail" runat="server" Text="Email:" Width="90px"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtEmail" runat="server" CssClass="cText" Width="150px" MaxLength="75"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:CheckBox ID="chkOther" runat="server"
AutoPostBack="true" />
</td>
<td class="cLabel" style="width: 15%">
<asp:Label ID="lblOther" runat="server" Text="Other:" Width="90px "></asp:Label>
</td>
<td>
<asp:TextBox ID="txtOther" runat="server" CssClass="cText" Width="150px" MaxLength="75"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="4">
<div class="buttons">
<span id="span2" class="cBtnLeft"><span class="cBtnMid"><span class="cBtnRight">
<asp:Button ID="btnDownLoad" runat="server" Width="65px" CssClass="cBtnRight" Text="Download"
OnClick="btnDownLoad_Click"/>
</span></span></span><span id="span1" class="cBtnLeft"><span class="cBtnMid"><span
class="cBtnRight">
<asp:Button ID="btnCancel" runat="server" Width="65px" CssClass="cBtnRight" Text="Cancel"
Visible="true" OnClick="btnCancel_Click" />
</span></span></span>
</div>
</td>
</tr>
</table>
</div>
</dx:PanelContent>
</PanelCollection>
</dx:ASPxPanel>
</dx:PopupControlContentControl>
</ContentCollection>
</dx:aspxpopupcontrol>
</div>
Usercontrol where the popup user control is called
<asp:Panel runat="server" ID="pnlCategoryDetail" Width="100%">
<dx:ASPxDataView ID="dvMARCCategoryDetail" runat="server" Width="100%"
ClientInstanceName="dvMARCCategoryDetail" style="clear: both" ColumnCount="2" RowsPerPage="2" OnPageIndexChanged="dvMARCCategoryDetail_PageIndexChanged">
<itemtemplate>
<table>
<tbody>
<tr>
<td>
<table>
<tr>
<td>
<asp:Image ID="ModelImage" runat="server" ImageUrl='<%#Eval("ImageUrl") %>'>
</asp:Image>
</td>
<td>
<div style="width: 5px" class="Spacer">
</div>
</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td>
<asp:Label ID="ModelLabel" runat="server" Text='<%# Eval("DocumentName") %>' Font-Bold="True"
>
</asp:Label></td>
</tr>
<tr>
<td style="text-align:left;padding-bottom:1em;">
<asp:Label ID ="txtText1" runat="server" Text="The May edition of News Brief contains seven newsworthy articles"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID ="txtText2" runat="server" Text="Suggested Subject Line: The May 2014 News Brief has arrived!"></asp:Label>
</td>
</tr>
<tr>
<td style="white-space:nowrap;">
<a id="clink2" style="width:60px">Content Link 1</a>
<asp:ImageButton ID="ImageButton2" runat="server" OnClick="btnArrow_Click" ImageUrl="~/Images/DownloadArrow.png" ToolTip="Download Item" style="padding-top:8px"/>
<asp:ImageButton ID="ImageButton1" runat="server" OnClick="btnAdd_Click" ImageUrl="~/Images/Add.png" ToolTip="Add Item" style="padding-top:8px"/>
</td>
<td> </td></tr>
</table>
</td>
</tr>
</tbody>
</table>
</itemtemplate>
<paddings padding="0px" />
<itemstyle height="50px">
</itemstyle>
</dx:ASPxDataView>
</asp:Panel>
<div id="divCategoryPopup" runat="server">
<downloadPopUp:categoryPopup id="ctlPopUp" runat="server"></downloadPopUp:categoryPopup>
</div>
On click of btnArrow_Click the popup user control should be displayed

Default Button not working while focus on different control

i have a search form in which i have certain controls (TextBox,DropDownList,CheckBox etc.) i have a search button in which the code for getting the result set if written.I want search button click event to get fired when i hit enter button,for this is have written
<form id="form1" runat="server" defaultbutton="btnSearch">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
</telerik:RadCodeBlock>
<telerik:RadDatePicker ID="RadDatePicker1" Style="display: none;" MinDate="01/01/1900"
MaxDate="12/31/2100" runat="server">
<ClientEvents OnDateSelected="dateSelected" />
</telerik:RadDatePicker>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25" align="center" valign="middle">
<table width="96%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="400" align="left" valign="top">
<span style="color: #FFFFFF; font-weight: bold;">
<asp:Label ID="lblName" runat="server"></asp:Label></span>
</td>
<td align="right" style="color: #FFFFFF; font-weight: bold;">
<asp:LinkButton ID="lbtnLogout" runat="server" Text="Logout" ForeColor="#FFFFFF"
Font-Bold="true" OnClick="lbtnLogout_Click">Logout</asp:LinkButton>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="10" align="center" valign="middle">
</td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#FFFFFF">
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="background: url(../img/bg02.png) #FFFFFF no-repeat top right;">
<tr>
<td align="left" valign="middle">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="250" align="left">
<img src="../img/goDigital_Logo01.png" width="198" height="91">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="3" align="center" valign="middle" style="background: url(../img/bg01.png) no-repeat;">
<asp:Label ID="lblError" runat="server" ForeColor="Red"></asp:Label>
<asp:UpdateProgress ID="UpdateProgress2" runat="server">
<ProgressTemplate>
<table cellpadding="0" cellspacing="0" width="140">
<tr>
<td width="26">
<asp:Image ID="Image3" runat="server" ImageAlign="AbsMiddle" Width="16px" Height=" 16px"
CssClass="PreLoader" ImageUrl="~/Images/preloader-square.gif" />
</td>
<td class="HD1b">
Please wait...
</td>
</tr>
</table>
</ProgressTemplate>
</asp:UpdateProgress>
</td>
</tr>
<tr>
<td align="left" valign="top">
<table width="100%" border="0" cellspacing="2" cellpadding="1" style="background: url(../img/bg-shadow.png) repeat-x center bottom;">
<tr>
<td width="20" class="color2">
</td>
<td width="100" class="color2">
<strong>Vendor Code</strong>
</td>
<td width="5">
<strong>:</strong>
</td>
<td colspan="2">
<table cellpadding="0" cellspacing="0" width="80%">
<tr>
<td>
<strong>
<telerik:RadComboBox ID="radtxtVendorCode" runat="server" EmptyMessage="Select Vendor Code"
EnableLoadOnDemand="true" EnableVirtualScrolling="true" Filter="Contains" HighlightTemplatedItems="true"
Height="180px" Style="margin-left: 0px" Width="100%">
<WebServiceSettings Method="GetVendorCode" Path="AccountSearch.aspx" />
</telerik:RadComboBox>
</strong>
</td>
</tr>
</table>
</td>
<td width="130" class="color2">
<strong>Invoice Date</strong>
</td>
<td width="5">
<strong>:</strong>
</td>
<td>
<strong>
<telerik:RadDatePicker ID="RadDPInvoiceDateFrom" runat="server">
<Calendar ID="Calendar3" runat="server" EnableKeyboardNavigation="true">
</Calendar>
</telerik:RadDatePicker>
</strong>
</td>
<td>
<strong>To</strong>
</td>
<td>
<strong>
<telerik:RadDatePicker ID="RadDPInvoiceDateTo" runat="server">
<Calendar ID="Calendar4" runat="server" EnableKeyboardNavigation="true">
</Calendar>
</telerik:RadDatePicker>
</strong>
</td>
</tr>
<tr>
<td class="color2">
<strong>Vendor Name</strong>
</td>
<td>
<strong>:</strong>
</td>
<td colspan="2">
<table cellpadding="0" cellspacing="0" width="80%">
<tr>
<td>
<strong>
<telerik:RadComboBox ID="radtxtVendorName" runat="server" EmptyMessage="Select Vendor Name"
EnableLoadOnDemand="true" EnableVirtualScrolling="true" Filter="Contains" Height="180px"
HighlightTemplatedItems="true" Style="margin-left: 0px" Width="100%">
<WebServiceSettings Method="GetVendorName" Path="AccountSearch.aspx" />
</telerik:RadComboBox>
</strong>
</td>
</tr>
</table>
</td>
<td class="color4">
<strong>Invoice Amount</strong>
</td>
<td>
<strong>:</strong>
</td>
<td>
<strong>
<telerik:RadNumericTextBox ID="RadtxtInvoicFromAmt" runat="server" Culture="en-IN"
EmptyMessage="From Amount" Width="120px">
<EmptyMessageStyle Font-Italic="True" />
</telerik:RadNumericTextBox>
</strong>
</td>
<td>
<strong>To</strong>
</td>
<td>
<strong>
<telerik:RadNumericTextBox ID="RadtxtInvoicToAmt" runat="server" Culture="en-IN"
EmptyMessage="To Amount" Width="120px">
<EmptyMessageStyle Font-Italic="True" />
</telerik:RadNumericTextBox>
</strong>
</td>
</tr>
<tr>
<td class="color1">
<strong>Print Ref. No</strong>
</td>
<td>
<strong>:</strong>
</td>
<td width="160">
<strong>
<telerik:RadTextBox ID="RadtxtPrintRefNo" runat="server" EmptyMessage="Enter Print Ref No"
Width="160px">
<EmptyMessageStyle Font-Italic="True" />
</telerik:RadTextBox>
</strong>
</td>
<td rowspan="3" align="left" valign="top">
<strong>
<img src="../img/digital1.jpg" width="160" height="119"></strong>
</td>
<td class="color4">
<strong>Transaction Date</strong>
</td>
<td>
<strong>:</strong>
</td>
<td>
<strong>
<telerik:RadDatePicker ID="RadDTTxnFromDate" runat="server">
<Calendar ID="Calendar1" runat="server" EnableKeyboardNavigation="true">
</Calendar>
</telerik:RadDatePicker>
</strong>
</td>
<td>
<strong>To</strong>
</td>
<td>
<strong>
<telerik:RadDatePicker ID="RadDTTxnToDate" runat="server">
<Calendar ID="Calendar2" runat="server" EnableKeyboardNavigation="true">
</Calendar>
</telerik:RadDatePicker>
</strong>
</td>
</tr>
<tr>
<td class="color4">
<strong>Invoice No</strong>
</td>
<td>
<strong>:</strong>
</td>
<td>
<strong>
<telerik:RadTextBox ID="RadtxtInvoicNo" runat="server" EmptyMessage="Enter Invoic No"
Width="160px">
<EmptyMessageStyle Font-Italic="True" />
</telerik:RadTextBox>
</strong>
</td>
<td>
</td>
<td class="color4">
<strong>NEFT / Chq No</strong>
</td>
<td>
<strong>:</strong>
</td>
<td>
<strong>
<telerik:RadTextBox ID="RadtxtneftNoFrom" runat="server" EmptyMessage="Enter From Neft No"
Width="120px">
<EmptyMessageStyle Font-Italic="True" />
</telerik:RadTextBox>
</strong>
</td>
</tr>
<tr>
<td valign="top" class="color4">
<strong>Currency</strong>
</td>
<td valign="top">
<strong>:</strong>
</td>
<td valign="top">
<strong>
<telerik:RadComboBox ID="radtxtCurrencyCode" runat="server" Height="121px" HighlightTemplatedItems="true"
Filter="Contains" EmptyMessage="Select Currency" EnableLoadOnDemand="true" EnableVirtualScrolling="true"
Width="163px">
<WebServiceSettings Method="GetCurrencyCode" Path="AccountSearch.aspx" />
</telerik:RadComboBox>
</strong>
</td>
<td valign="top" class="color4">
<strong>Remarks / Naration</strong>
</td>
<td valign="top">
<strong>:</strong>
</td>
<td colspan="4" valign="top">
<strong>
<asp:TextBox ID="txtRemarks" runat="server" Width="330px" TextMode="MultiLine"></asp:TextBox>
</strong>
</td>
</tr>
<tr>
<td align="left" valign="top">
<asp:ImageButton ID="btnSearch" runat="server" ImageUrl="~/img/btnsearch.png" Width="125"
Height="45" OnClick="btnSearch_Click" OnClientClick="return checkdate();" />
</td>
<td colspan="4" valign="top">
<asp:ImageButton ID="btnClear" runat="server" ImageUrl="~/img/btnclear.png" Width="125" Height="45" OnClick="btnClear_Click" />
</tr>
</table>
</td>
</tr>
<tr>
<td height="120" align="left" valign="top" bgcolor="#C2E8F3">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<telerik:RadGrid ID="rdSearchResult" runat="server" GridLines="None" AllowPaging="True"
SkinID="MySkin" AutoGenerateColumns="false" AllowMultiRowSelection="True" AllowSorting="false"
OnNeedDataSource="rdSearchResult_NeedDataSource" Skin="Windows7">
<PagerStyle AlwaysVisible="True" />
<MasterTableView>
<CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
<Columns>
<telerik:GridTemplateColumn HeaderText="Supp Code">
<ItemTemplate>
<%# Eval("suppcode")%></ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Party">
<ItemTemplate>
<%# Eval("party_name")%></ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Ref No">
<ItemTemplate>
<%# Eval("print_refno")%></ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Currency">
<ItemTemplate>
<%# Eval("currcode")%></ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Invoice No">
<ItemTemplate>
<%# Eval("invno")%></ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Invoice Amt">
<ItemTemplate>
<%# Eval("invAmt")%></ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Invoice Date">
<ItemTemplate>
<asp:Label ID="lblDate" runat="server" Text='<%#Convert.ToDateTime(Eval("invdt")).ToString("dd/MM/yyyy") %>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<PagerStyle AlwaysVisible="True"></PagerStyle>
</MasterTableView>
<ClientSettings ClientEvents-OnRowDblClick="rdSearchResultDblClick" EnableRowHoverStyle="true">
<ClientEvents OnRowDblClick="rdSearchResultDblClick"></ClientEvents>
<Selecting AllowRowSelect="true" />
</ClientSettings>
<SelectedItemStyle BackColor="#C2E8F3" />
</telerik:RadGrid>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td bgcolor="#C44533">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
but this works only when i click somewhere out (take focus off the searching control)and then hit enter
Please suggest
You can place your controls inside a asp:panel and set it's default button.
<asp:Panel ID="p" runat="server" DefaultButton="myButton">
<%-- Text boxes here --%>
<%-- drop down here --%>
.....
<asp:Button ID="myButton" runat="server" />
</asp:Panel>
set a default button to be clicked when the user presses Enter? Simply add the following line to your page's Load event, replacing "btnSearch" with the name of your button. It uses a hidden Page method called RegisterHiddenField and works splendidly:
Page.RegisterHiddenField("__EVENTTARGET", "btnSearch")
Source :-Default Button
try using Button and its UseSubmitBehavior
<asp:Button ID="btnSearch" runat="server" Width="125" Height="45" UseSubmitBehavior="true" />
instead of Image button.
You can easily set the background image of button using css. so don't use Image Button
Place this script below the scriptmanager:
<script type="text/javascript">
var $p = Telerik.Web.UI.RadComboBox.prototype;
var keyDownHandler = $p._onKeyDown;
$p._onKeyDown = function (e) {
var oReturnValue = e.returnValue;
var oPreventDefault = e.preventDefault;
var keyCode = e.keyCode || e.which;
if (keyCode === 13)
e.preventDefault = null;
keyDownHandler.call(this, e);
if (keyCode === 13) {
e.returnValue = oReturnValue;
e.preventDefault = oPreventDefault;
}
};
</script>

how find and give css class to a control in side layout template of listview?

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";
}
}

Categories

Resources