I have a code that gives me the item selected in a dropdownlist but I canĀ“t make it work for a dropdowncheckbox. In the following:
var Activity= document.getElementById("Cbo_ActivityTypes").value
var Brand = document.getElementById("Cbo_Brand").value
Alert (Activity)
Alert (Brand)
Alert (activity) shows a window with the ID of the item selected, but the Alert(Brand) shows a windows saying undefined. It doesn't recognize that there were items selected in the field Brand.
Codes that load each box:
asp:DropDownList ID="Cbo_ActivityType" runat="server" Width="143px" AutoPostBack="True">
asp:DropDownCheckBoxes ID="Cbo_Brand" runat="server" Width="180px" UseSelectAllNode="False">
Anyone can give some help on this issue?
It is an asp webControl. So to get your Id in html use '<%=ID.ClientID%>'
var Activity= document.getElementById("<%=Cbo_ActivityTypes.ClientID%>").value
var Brand = document.getElementById("<%=Cbo_Brand.ClientID%>").value
Related
<telerik:RadComboBox ID="radcmb" runat="server" MarkFirstMatch="true">
</telerik:RadComboBox>
radcmb.Items.Clear();
radcmb.Text = String.Empty;
radcmb.DataSource = DS;
radcmb.DataTextField ="DESCRIPTION";
radcmb.DataValueField ="ID";
radcmb.DataBind();
and i am setting the datasource of the combo box on page_load event, the problem is whenever i have select any item from the combo box and click outside / any other section of the page, its de-select the item and select the first item from the list.
i tried below solution - but it didn't helped me.
RadComboBox changing selected item when clicking on other parts of page
Run through Site_materials table, any matches found store them in 'NumberOFDeliveries',
which is the ID of the label that should display them on screen.
//DELIVERIES
int NumberOfDeliveries = (from Deliveries in db.Site_Materials
where Deliveries.Diary_Entry_Id == this.DiaryEntryId
select Deliveries).ToList().Count();
if (NumberOfDeliveries > 0)
{
NoOfDeliveriesOnSite.Text = System.Convert.ToString(NumberOfDeliveries);
}
else
{
NoOfDeliveriesOnSite.Text = "0";
}
If I use the below label in my aspx page t displays as expected. But I have a problem trying to display it where i want... inside FooterTemplate/Panel/SecurePanel/Div
<FooterTemplate>
<asp:Panel runat="server" ID="AllLinks" HorizontalAlign="Center" Width="600px" >
<mesh:SecurePanel runat="server" ID="EmployeeLink" CssClass="SmallBoxLink" WebMasters="true" Admins="true" Clients="true" Employees="true">
<div style="height:25px; margin-top:12px; margin-bottom:12px;">
<asp:Label ID="Delivery" runat="server" Text="Deliveries=" /><asp:Label ID="NoOfDeliveriesOnSite" runat="server" />
As I said this code works fine and displays the correct amount(When used at diff places on the aspx page) BUT when i try to display it where I want I get the error:
from the cs. page stating 'NoOfDeliveriesOnSite' does not exist.
any ideas as to why
if it's in the footer, you will need to set the control number to -1. In this example, i have a label in the footer that I want to get a handle on:
dim myLabel as label
myLable = myDataRepeater.Controls(myDataRepeater.Controls.Count - 1).FindControl("lableName")
If there is a control you're trying to find within the user control, you may need to add a notehr .FindControl method Ie:
myLable = myDataRepeater.Controls(myDataRepeater.Controls.Count - 1).FindControl("lableName").findControls("anotherControl")
You have to find controls inside whatever container they're in.
You will want to add this above the code sample that you gave in your question, so that your reference to that variable will be valid:
SecurePanel EmployeeLink = (SecurePanel)AllLinks.FindControl("EmployeeLink");
Label NoOfDeliveriesOnSite = (Label)EmployeeLink.FindControl("NoOfDeliveriesOnSite");
Depending on what you're FooterTemplate is for (GridView, FormView, etc), you will probably need to find the "AllLinks" Panel inside that first as well.
I have written a method that retrieves data from the database and returns a datatable comprising of three columns.
This datatable I am binding to a gridview control after hiding the ID field.
DataTable dt = _qbObj.getAllTags();
dvTags.DataSource = dt;
BoundField bfName = new BoundField();
bfName.DataField = dt.Columns["Name"].ToString();
bfName.HeaderText = "Name";
BoundField bfId = new BoundField();
bfId.DataField = dt.Columns["ID"].ToString();
bfId.Visible = false;
BoundField bfDesc = new BoundField();
bfDesc.DataField = dt.Columns["Description"].ToString();
bfDesc.HeaderText = "Description";
dvTags.Columns.Add(bfId);
dvTags.Columns.Add(bfName);
dvTags.Columns.Add(bfDesc);
dvTags.DataBind();
To this gridview control, I want to add an edit button, which should pop-up a jquery modal dialog box where I can enter the updated details.
I realize that I can go with a , but the problem is that I need to pop that modal dialog box without refreshing the page, and the doesn't exactly have great support for scripting.
So inside my gridview I inserted this, an Item Template.
<asp:GridView ID="dvTags" runat="server" CssClass="labs-grid-view"
AutoGenerateColumns="False" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnEdit" runat="server" Text="Edit" OnClick="dvTagEdit" CommandName="UpdateRecord"
CommandArgument='<%# Eval("ID") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Now after I am done editing the gridview doesn't update automatically, and hence I have a dedicated refresh grid button which deletes the existing "dynamically inserted columns" using this code :-
int noOfRows = dvTags.Columns.Count;
if (noOfRows > 1)
{
dvTags.Columns.RemoveAt(noOfRows - 1);
dvTags.Columns.RemoveAt(noOfRows - 2);
dvTags.Columns.RemoveAt(noOfRows - 3);
// THERE ARE A TOTAL OF **THREE** COLUMNS
}
But the problem is that after refreshing the page a couple of times, my button inside the ItemTemplate disappears and in the html is replaced with an " "
Please help me find the error. I'm thinking there is a better and easier way to achieve this. If so I'm open to them.
Thanks for reading,
Abijeet.
A few things to consider:
First, can you post your code behind for your ItemCommand event, which is rendering the modal popup and which is performing the update? It could be that your refresh after edit is not processing properly.
Second, instead of doing your databinding "inline" on your GridView, consider using the RowDataBound event within the Gridview. You can detect which row is being generated (header, data, footer) and you can properly create your edit button in there. Better yet, you can access your button from within this method and simply set the CommandArgument to your Id.
Third, when using the asp button in your GridView, it will trigger the "ItemCommand" event when clicked, which will cause a postback.
I'd recommend having a simple link in your template column, or something that you can use to trigger a jQuery modal, and you can setup a static naming convention for your items that will properly retrieve the data to put into your modal popup for editing. Then from there you should be able to process your update as normal.
I hope something in here helps.
I am working with Telerik Ajax control RadOrgChart
I want to capture when a node was clicked (in fact right clicked) in an OrgChart. I want the event to pass the ID of the node clicked.
I cannot find any such event in OrgChart.
Can anyone please suggest how to do it.
Thanks
Reading the documentation i see that RadOrgChart doesnt have a event handler for node click, so i think you could make your own ItemTemplate and handle the click of the items of the template, something like this.
<telerik:RadOrgChart ID="RadOrgChartDirectReports1" EnableViewState="true" Skin="Office2010Silver"
runat="server">
<ItemTemplate>
<asp:Button CausesValidation = "false" OnClick="LinkButton_Click" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "EmployeeId")%>'
runat="server" Text = "Click" ID="LinkButtonNode"></asp:Button>
</ItemTemplate>
</telerik:RadOrgChart>
in this example you put a button inside a item, so, you can handle the button click.
Thanks Ewerton.
I found a better way to do it on client side instead.
Each of the telerik orgchart nodes have default css class, so something like this work:
$telerik.$(".rocItem").click(function (e) {
var orgChart = $find("<%= RadOrgChart1.ClientID %>");
var index = orgChart._extractGroupItemFromDomElement(e.target).get_index();
var hierarchicalIndex = orgChart._extractNodeFromDomElement(e.target)._getHierarchicalIndex();
hierarchicalIndex = orgChart._getRealHierarchicalIndex(hierarchicalIndex);
alert("Clicked " + hierarchicalIndex);
})
I am developing a movie theater seats booking website,. I have placed images as Seats in asp:gridview(all cells) using ImageButton. For the selected seat, when the user clicks on it, the ImageButton(cell) is set for that seat.
I need to get the seat that was clicked from the gridview. How am I able to do this?
You can find the ImageButton on the RowCommand event of the grid view.
Code part:
string strType="";
ImageButton img = (ImageButton)e.CommandSource;
strType = img.Attributes["TypeID"].ToString();
Designer part:
<asp:ImageButton ID="imgBtn" runat="server" ImageUrl="image"
TypeID="..Give your value.." />