I have a custom control with a collection-type field.
When i run the app in debug mode and try to add items to the field, the XAML editor show the error:
Error XHR0015 Failed to add HelloItem to ObservableCollection`1.
Unable to find element.
Why the error? How to solve the problem?
The source code: https://github.com/jhonToni/CustomComponentApp
You couldn't add a new HelloItem in XAML editor in runtime. After you add a new HelloItem, you need to recompile it.
Related
I want to export Telerik RadRichTextBox to a variable.
(new RtfFormatProvider()).Export(RadRichTextBox1.Document)
But this code will show this error:
Cannot convert from RadDocument to RadFlowDocument
You probably don't reference the appropriate RtfFormatProvider class.
Check your usings, or explitly call:
(new Telerik.Windows.Documents.FormatProviders.Rtf.RtfFormatProvider()).Export(RadRichTextBox1.Document)
I am using Visual Studio 2015, using the ASP.NET framework and I'm having problems. I can't fix my error and would like some help.
Front End:
<asp:Button OnClick="imgBtnSortTickets_Click" ID="imgBtnSortTickets"
runat="server" Text="Sort" SkinID="Buttons" />
Code-behind:
protected void imgBtnSortTickets_Click(object sender, EventArgs e)
{}
I am working with source code and everything works fine until I add a button and add the onclick attribute. When I reference to my code behind the onclick will always get errors if it's to a new event click method. I even get this error when I reference to a javascript function. My friend however doesn't get this error when add new buttons. But when I try to run their code that they just added which worked on their end it won't work on mine. So basically If any new references are made to the code behind file using the onClick event I will receive an error even though I won't receive one on old ones? The following will be my error.
Compiler Error Message: CS1061: 'ASP.triptickets_aspx' does not contain a definition for 'imgBtnSortTickets_Click' and no extension method 'imgBtnSortTickets_Click' accepting a first argument of type 'ASP.triptickets_aspx' could be found (are you missing a using directive or an assembly reference?)
How can I fix this because neither myself or my friend know what's wrong since this exact button and event will work. I apologize if I didn't call something correctly because I'm an entry level developer.
It seems some of your autogenerated code got deleted somehow, and now your markup and your codebehind are out of sync.
You can fix this manually, but it's probably easier just to do it this way:
Edit the .aspx file in source code view and completely remove the markup for the button.
Access the .aspx page in designer view and add the button back by dragging a button from the toolkit.
Set the ID (and other properties) of the button using the Properties UI.
In the designer view, double click the button to autogenerate the scaffolding for the click event handler.
Edit the click event handler, being careful not to change its name or any part of its prototype.
If this fails, open your project in Visual Studio and do a global search of all files in the solution that contain "imgBtnSortTickets_Click". Based on the error, you should find some markup that references it. Whatever control is referencing it, delete the entire control, then recreate it using the designer. If you are unsure how to edit the markup directly, edit your post and paste the code so we can help you.
In the Lemoon admin I simply am creating a new Content Type called 'test' with just a simple text box titled 'positionTitle' to start with for testing. It gets created just fine, however once I create a new 'test' object in the site i run into problems. I give it a title, some body text, and the postionTitle as it asks - save it and all is well. However no matter what I change or try I keep receiving this error regarding Content.Title. http://d.pr/i/KVdb
I am using the default 'PageTemplate' as the template for the page so its requesting the Title obviously, however I have it filled out?!
Where am I going wrong, what am I missing? I have poured through the Lemoon docs with no luck.
Thanks in advance.
The PageTemplate is strongly typed to the Page content type as you see in the code-behind of the template. Since you are passing in a Test content type the Content property in the template will be null.
Normally when you create a new content type you will also need to create a new template for rendering it. So what you need to do is create a template for your Test content type. See http://www.lemoon.com/developers/programming/aspnet/templates.
I am using the following code to update a listbox, this recieving a list from a Web service:
client.userKeywordsCompleted += new EventHandler<userKeywordsCompletedEventArgs>(client_userKeywordsCompleted);
client.userKeywordsAsync();
Using:
void client_userKeywordsCompleted(object sender, userKeywordsCompletedEventArgs e)
{
string result = System.Convert.ToString(e.Result);
for (int i = 0; i < e.Result.Count; i++)
{
ListBoxItem lbitem = new ListBoxItem();
lbitem.Name = "lb_" + i;
lbitem.Content = e.Result[i];
lbitem.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(ListBoxItem_DoubleClickEvent), true);
listBox1.Items.Add(lbitem);
}
This works fine, as I use it when the Child window loads, so the ListBox gets the list from the database, however, when a user selects one of the items in the ListBox, they have the option to edit the selected item. So once the edit is in place, there is an edit button, which updates the column in the table in the database. So then on the button click, I am again calling the aforementioned code to update the ListBox with the new credentials. However, this brings back the error:
"Value does not fall within the expected range."
Why can I not call the Web method on the button click, as all it is doing is refreshing the ListBox?
This might be due to the fact that you are trying to add a ListBoxItem with the same name to the page.
If you want to refresh the content of the listbox with the newly retrieved values you will have to first manually remove the content of the listbox other wise your loop will try to create lb_1 again and add it to the same list.
Look here for a similar problem that occurred Silverlight: Value does not fall within the expected range exception
I had from a totaly different reason the same notice "Value does not fall within the expected range" from the Visual studio 2008 while trying to use the:
Tools -> Windows Embedded Silverlight Tools -> Update Silverlight For Windows Embedded Project.
After spending many ohurs I found out that the problem was that there wasn't a resource file and the update tool looks for the .RC file
Therefor the solution is to add to the resource folder a .RC file and than it works perfectly.
I hope it will help someone out there
In case of WSS 3.0 recently I experienced same issue. It was because of column that was accessed from code was not present in the wss list.
I am trying to use this solution to access items inside a telerik menu item:
ascx code:
<asp:Label ID="DivLeave" runat="server"></asp:Label>
In the ascx.cs file I run this code to disable the asp label
RadMenuItem expenses = RadMenu1.FindItemByText("Expenses");
Label DivLeave = (Label)expenses.FindControl("DivLeave");
DivLeave.Visible = false;
but I get this error when I try to run the code:
{"Object reference not set to an instance of an object."}
Can anyone tell me how to fix this problem. I really need to run this server side as code surrounding the above code does some work server side and it will all fit in neatly...
Kind regards
This is because the name of your label is not "DivLeave" when the HTML for your form is rendered. Since it is inside a user control it will be a combination of the user control name on the page and then "DivLeave". You should be able to see the name by looking at the code behind. Also why can't you just reference DivLeave.Visible without using the FindControl? Its an ASP.NET control with the runat server attribute so it should be available to you.
Can you do a quickwatch for 'expenses' object in Visual Studio and see if 'DivLeave' is available? It may so happen that:
The label control is available but at a different level in the object.
The label control itself is not getting added to the parent 'expenses'.
Also, it would be a good idea to do a null check for expenses and DivLeave objects before accessing them.