How do I open DropDown of RadComboBox on asp:Button click? Both RadComboBox and Button are inside EditItemTemplate of RadGrid.
My requirement is: I had to open DropDown of RadComboBox ("ddlAccountCode" in below HTML code) on a click of button ("btnSearch" in below HTML code).
Below is the HTML code of RadComboBox and Button
<telerik:GridTemplateColumn UniqueName="AccountCode" HeaderText="Account Code">
<ItemTemplate>
<asp:Label ID="lblAcCode" runat="server" Text='<%# Eval("AccountCode")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblAcCode2" runat="server" Text='<%# Eval("AccountCode") + " - " + Eval("AccountDescription")%>' Visible="false"></asp:Label>
<telerik:RadComboBox ID="ddlAccountCode" runat="server" Height="200" Width="240" DropDownWidth="310" HighlightTemplatedItems="true" CausesValidation="true"
OnItemsRequested="ddlAccountCode_ItemsRequested" EnableItemCaching="true" ShowDropDownOnTextboxClick="false" EnableLoadOnDemand="True" ShowMoreResultsBox="true" EnableVirtualScrolling="true" MarkFirstMatch="True" AllowCustomText="true"
Filter="Contains" AppendDataBoundItems="true" DataTextField="AccountDescription" DataValueField="AccountCodeID" AutoPostBack="true" OnSelectedIndexChanged="ddlAccountCode_SelectedIndexChanged">
</telerik:RadComboBox>
<telerik:RadButton id="btnSearch" runat="server" text="Search" OnClick="btnSearch_Click">
</telerik:RadButton>
</EditItemTemplate>
</telerik:GridTemplateColumn>
I am doing searching/filtering in RadComboBox on a button click. All is working fine except when I type/search anything in textbox of RadComboBox and click on button to search, the dropdown of RadCombo does not open up. Due to this, every time, I have to manually open the dropdown to see the result of searched text in RadComboBox.
Below line of code is working fine for my requirement:
protected void btnSearch_Click(object sender, EventArgs e)
{
GridEditableItem editedItem = (sender as Button).NamingContainer as GridEditableItem;
RadComboBox combo = (RadComboBox)editedItem.FindControl("ddlAccountCode");
combo.OpenDropDownOnLoad = true; // opens dropdown of RadComboBox
}
Related
i wrote a code to show varified as he enters eany data. so i have 2 button to varify and then close. with label to display whether his email id is varified or not...
the code is
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="Panel1" TargetControlID="btn"
CancelControlID="btnClose" BackgroundCssClass="modalBackground" >
<asp:Label ID="Label1" runat="server" Text="Enter Your Registered Email Id"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Label ID="Label2" runat="server" Text="Label" ></asp:Label>
<asp:Button ID="Button2" runat="server" CssClass="btn btn-info" OnClick="Button2_Click" Text="Varify" />
<asp:Button ID="btnClose" runat="server" Text="Close" />
code behind code is..
protected void Button2_Click(object sender, EventArgs e)
{
Label2.Visible = true;
Label2.Text = "Valid User";
Label2.ForeColor= System.Drawing.Color.Green;
//ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "showModal()", true);
// ModalPopupExtender1.Show();
}
but as i click on Button2 it closes the model..then i have to open again to see the output...I want to show the label text with out closing the ModalPopupExtender...Help me
I think postback cause this. I don't know so much about ModalPopupExtender but I can recommend you to use Jquery for button2 click and in click event make an ajax call and check whether your email is valid or not.
<asp:DataList ID="DataList1" runat="server" RepeatColumns="5" RepeatDirection="Horizontal"
onitemcommand="DataList1_ItemCommand"
onselectedindexchanged="DataList1_SelectedIndexChanged"
ondatabinding="DataList1_DataBinding">
<ItemTemplate>
<asp:HiddenField ID="Hdnqid" runat="server" Value='<%# Bind("Id") %>' />
<asp:HiddenField ID="HidnResultStatus" runat="server" Value='<%# Bind("ResultStatus") %>' />
<asp:Button ID="Butto" runat="server" Text='<%#Eval("Id") %>' CommandName="Save&Next"
CommandArgument='<%#Eval("Id") %>' />
</ItemTemplate>
</asp:DataList>
I want to change color of button accourding to value of table.
One way of doing this is using OnDataBound event of the data list. In the event you can get the button as well as your data item properties. Here you can change the properties of the button as below
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
Button button = e.Item.FindControl("Butto") as Button;
HiddenField HidnResultStatus = e.Item.FindControl("HidnResultStatus") as HiddenField;
string property = DataBinder.Eval(e.Item.DataItem, "colorproperty") as string;
//Here you can change the button color based on the value
if(HidnResultStatus.Value=="")
button.ForeColor = System.Drawing.Color.Black;
if(HidnResultStatus.Value=="1")
button.ForeColor = System.Drawing.Color.Brown;
}
Web.UI.Controls.TextBox
in my aspx page i have used-
<asp:TextBox ID="TextBox1" runat="server" OnTextChanged="tmaintextchanged" ></asp:TextBox>
in my code behind :
<asp:Label ID="show" runat="server" ></asp:Label >
protected void tmaintextchanged(object sender, EventArgs e)
{
show.Text = "working";
}
when I am executing this ,Why is the text of label "show" not changing.Kindly help. Am i missing any configuration to the Text box.
You need to set autopostback on TextBox control:
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true" OnTextChanged="tmaintextchanged" ></asp:TextBox>
Update
see this post:
How do I make a Textbox Postback on KeyUp?
After spending hours on it i still couldnt find the Solution,Plaese Help.
I am Developing a Website where I have a Gridview with data,i have a linkbutton as a templatefield in one of the Columns which onClick is doing a postback and displaying the records in a modalpoupextender,which is inside a seperate asp panel,
i have edit,update,delete buttons in that popup which are doing postback and functioning well.
Remmember i have not used UpdatePanel anywhere,as i do not have that kind of requirement.
Now,i have another LinkButton on the Page(not in gridview),which has some other functinality after OnClick postback,the problem is When i Click That LinkButton it first displays the ModalpopUp and then it does the postback and completes the function.The important part is that the Modal PopUp disappears just in seconds.
So,i just get a glimpse of Modalpopup whenever i click on the LinkButton.
I tried ModalPopUpExtender1.hide() at every Possible Place,but its not Working.
I am not sure how to disable that popup from appearing on LinkButton Click.Please Help me on it.I am in Trouble.
Thanks in Advance.
Here is my GridView Code:
<asp:GridView ID="dg_Task" runat="server" CssClass="gridview"
BorderWidth="1px"
Font-Names="Trebuchet MS" Font-Size="Small" AllowSorting="True"
AutoGenerateColumns="False" onrowdatabound="dg_Task_RowDataBound"
Width="100%" Height="143px"
onprerender="mergeDoc">
<Columns>
<asp:TemplateField HeaderText="Task">
<ItemTemplate>
<asp:Label ID="lbl_tid" runat="server" Text='<%#Bind("ID") %>'
Visible="False"></asp:Label>
<asp:LinkButton runat="server" ID="Lnk" ForeColor="Black"
CommandArgument='<%# Bind("ID") %>' Font-Underline="False" onclick="Title_Click"
Text='<%# Bind("Task") %>' Font-Names="Trebuchet MS"></asp:LinkButton>
</ItemTemplate>
<HeaderStyle Width="35%" />
<ItemStyle Height="2px" HorizontalAlign="Left" VerticalAlign="Top" />
</asp:TemplateField>
Here is The CodeBehind:
protected void Title_Click(object sender, EventArgs e)
{
ddown_status.Items.Clear();
var btnId = sender as LinkButton;
string id = btnId.CommandArgument;
btnUpdate.CommandArgument = id.ToString();
btnDelete.CommandArgument = id.ToString();
//Some Code which fills the details of my PopUp Fields
this.modalPopUpExtender1.Show();
}
Here is the another LinkButton(On Main Page) code:
protected void LinkButton1_Click(object sender, EventArgs e)
{
//here even i simple postback(Without any code) Triggers The PoPUp and Provides a Glimpse then the rest code runs
//sample code here
}
Please Help .Thanks
I need to
<asp:TemplateField HeaderText ="ename">
<ItemTemplate > <asp:Label ID="lbl2" Text ='<%#Eval("ID") %>' runat ="server" >
</asp:Label>
</ItemTemplate>
<EditItemTemplate >
<asp:TextBox ID ="textbox1" Text='<%#Eval("name")%>' runat ="server" ></asp:TextBox>
<asp:LinkButton ID ="link1" Text='<%#Eval("name")%>' runat ="server" ></asp:LinkButton>
</EditItemTemplate>
</asp:TemplateField>
i have an textbox and link button in Edit itemtemplate
based on the condition()
if(Text ='<%#Eval("ID") %>')
id=1 show textbox[edit item temalpate]
id=2 show link button[edit item temalpate]
id=3 show link button[edit item temalpate]
now in link button i have value [Text='<%#Eval("name")%>'] (eg:www.stackoverflow.com ,google.com)
so that one an user clicks on the link button open a new browser window and show that website show to open an new browser window on the clcik of the link button
Could you use a HyperLink control rather than a LinkButton?
eg
<asp:HyperLink id="hyperlink1"
NavigateUrl="<%#Eval('name')%>"
Text="<%#Eval('name')%>"
Target="_blank"
runat="server"/>
You can just bind to the OnClientClick event of the LinkButton. I would do all of this by implementing the OnDataBinding event for that control:
Eg:
// In your .aspx
<asp:LinkButton ID ="yourButton" runat="server" OnDataBinding="yourButton_DataBinding" />
//In your .cs
protected void yourButton_DataBinding(object sender, System.EventArgs e)
{
LinkButton btn = (LinkButton)(sender);
btn.Text = Eval("name");
btn.OnClientClick = string.Format("window.open('{0}', 'yourNewWindow'); return false;", Eval("name"));
}
If you need more info on how the javascript window.open works check out this link:
http://www.javascript-coder.com/window-popup/javascript-window-open.phtml
<asp:HyperLink id="hyperlink1" NavigateUrl="<%#Eval('name')%>" Text="<%#Eval('name')%>" Target="_blank" runat="server" />
before NavigateUrl we need to the code "http" as shown then it woks fine
NavigateUrl='<%# "http://" + Eval('name')%>'
can Add
OnClientClick="aspnetForm.target ='_blank';"
so on click it will call Javascript function an will open respective link in News tab.
<asp:LinkButton id="lbnkVidTtile1" OnClientClick="aspnetForm.target ='_blank';" runat="Server" CssClass="bodytext" Text='<%# Eval("newvideotitle") %>' />