.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal


problem parse xaml and blank spaces


Hi, I have a problem parsing an xaml with characters 
 and space blanks, the space that show me is different that show in Silverlight.

this is the code to parse the xaml

            xml_node = nodo.OuterXml;
            text = (System.Windows.Controls.TextBlock)XamlReader.Parse(xml_node);

            if (text.Height != double.NaN)
              text.Height = double.NaN;

            text.Text = text.Text.Replace(' ', (char)160);

            if (text.Visibility != Visibility.Collapsed)

And this is the code of xaml:

  <TextBlock x:Name="Elemento_300920102232365" Canvas.Left="121.488" Canvas.Top="125.682" Width="1705.799" Height="2169.455" Text="&#xD;&#xD;&#xD;Jamón de Bellota (reserva) / Pernil de Bellota (reserva)                         17'00 €&#xD;Anchoas del Cantábrico / Anchoves del Cantàbric  &

XAML Serialization Problem


I try to save (serialize) a XAML document. The background is that the user of the application should be able to change the XAML document dynamically.

This works fine with some basic controls but as soon as I have a datagrid inside the XAML, non of this works:

System.Windows.Markup.XamlWriter.Save throws:

Cannot serialize a generic type 'System.Collections.ObjectModel.ObservableCollection`1[Microsoft.Windows.Controls.DataGridColumn]'.

System.Xaml.XamlServices.Save throws:

Constructor on type 'System.ComponentModel.ComponentConverter' not found.

I already found in forum that XAML does not fully support generics, however, is there a solution for this? I'm a bit confused because if XAML can be read dynamically it should also be possible to save it...

I use .NET Framework 4.

Thanks for reply... any suggestion is very welcome.

Problem with ListView' SelectionChanged event


I have a listview (C#) with some items representing metadata objects. Near this listview I have a Panel where the structure of selected metadata object is shown.

When user selects one item I want to show my Panel (with structure of this item).

When user doesn't select any item or selects many items I want to hide my Panel.

It works but there are a lot of blinks during selection changes. I've prepared workaround to this issue by checking in SelectionChanged event whether the number of selected items changed (none -> one, one -> many, many -> one, one -> none). If the number changed so I show or hide the panel, in other cases I don't do anything.

But one blink is still here. When I just move one-item selection from one item to another then SelectionChanged occures 2 times (for previous selected item and then for next selected item). So my check works incorrectly in this case: one item selection changes to none selection (first SelectionChanged event) and panel becomes hidden, then none selection changes to one item selection (second SelectionChanged event) and panel becomes shown. So user sees blinks.

How can I detect whether user deselected all items at all or just moved the selection from one item to another.

Thanks a lot. Sorry for my English:)

user control event problem


so i created a user control and i contains an image button the problem is that whenevr i click the image button nothing happens what so ever. I have done every thing according to the book the only diffrence is that i load the usercontrol dynamicly here is sample of my code

public event EventHandler ImageClicked;

protected void image_Click(object sender, ImageClickEventArgs e)
        if (ImageClicked != null)
            ImageClicked(this, e);


in the webform class

autoshowcontrol show = (autoshowcontrol)Page.LoadControl("autoshowcontrol.ascx");
                    show.ImageClicked += new EventHandler(show_ImageClicked);


public void show_ImageClicked(object sender, EventArgs e)

ListAdded event problem



I'm trying to create an event receiver that enables content type management in a document library during library creation. The event receiver works fine when I'm creating a new document library, but it fails when I try to provision a new site containing a document library.

It fails when accessing the List property of the properties parameter, with the following error message :

List '$Resources:cmscore,ListNameDocuments;' does not exist at site with URL 'http://intranet-d.xxxxxxxx.net/w9'

My event handler looks like this:

public class

Clearing RadiobuttonList using jquery does not preserve its value when attached to textChanged event


Hello everybody,

Well, i have a simple ASP.NET 3.5 page with a Radiobuttonlist with 2 items (Yes/NO). there are also 2 Buttons. The 1st button has a client side jQuery code that clears the selected value in the radiobuttonlist. The second button just postback the page when clicked and has no event handler.

Now, everything works fine, so when we select a value in the radiobuttonlist (ex: Yes), then we click the 1st button, the value is cleared, and clicking on the 2nd button, the page posts back and the radiobuttonlist control will not have any value selected. (That's GOOD for now).

Now, if we attach the textChanged or SelectedIndexChange events to the RadioButtonList (with no server side code in them), and repeat the above senario, what will happen is that after postback, the radiobuttonlist value will NOT BE CLEARED, and it will revert to the last selected value before postback. This is very weird. I don't know why it behaved like this.

Have anyone faced this issue, and how can we solve this. Please Help.




Problem with calling asp button click event from Java script


Dear all ,


I m using these following lines of codes in my java script funtion Save()




var btnSave = document.getElementById('<%=btnSave.ClientID%>');


In ascx,

<asp:Button runat="server" style="display:

Post New Web Links

Attached Event Registering Problem in XAML vs. CS

Posted By:      Posted Date: October 11, 2010    Points: 0   Category :WPF


I spent hours searching for a solution to this, but did not find a proper one.

As stated in this post here, there seems to be a difference in how attached events are registered in XAML and in C#.

As described in the MSDN documentation , WPF requires you to implement two methods (AddXYZHandler, RemoveXYZHandler) in order to use an attached Event (XYZEvent) in XAML:


public static readonly RoutedEvent XYZEvent = EventManager.RegisterRoutedEvent("XYZ", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(XYZClass));

public static void AddXYZHandler(DependencyObject d, RoutedEventHandler handler)
 //event registration comes here

public static void RemoveXY

View Complete Post

More Related Resource Links

Pre_Init event handler problem


Hi all my friends

   I have to masterpages for my home page.

1. The first is for the annonymous users which has the login controls. its name is General_Anonymous.master.

2. The second one is for the logged in users which has a logout button and it hasn't the login controls in it. its name is General_LoggedIn.master.

in my default.aspx page I wrote the following code

protected void Page_PreInit(object sender, EventArgs e)
            if (Session["SupId"] == null && Session["CustomerId"] == null)
                this.MasterPageFile = "~/Masters/General_Anonymous.master";
                this.MasterPageFile = "~/Masters/General_LoggedIn.master";

Visual Studio designer event problem


Hi there

I have a small issue that I'm sure others have experienced - but haven't yet found a solution / workaround for this.

When adding controls to Visual Studio in designer you normally get a event button (the yellow flash light) in the properties window.

But when you nest a button inside a placeholder (for example) you cannot mark the button from the designer - only the placeholder! When trying to go into "split-view" on the designer you'll be able to mark the button in the bottom of the designer - but only properties and not the event button appers in the properties window!

I know that you can go into codebehind and manually add the event but I thiink it is really tiresome to do so if I don't have to...

I had a small hope that VS2010 the issue would be gone but sadly it isn't...

Anyone ever found a solution for this one?

Kind regards Thomas

Sharepoint 2010 List Added Event Problem

Hi All, I have created List Added Event Handler. In that Event I want to Add Custom Field in List as List is created. I get an Error "The Specified Program Requires    a newer version of windows" Is there ant solution for it. I have tried it also creating new instances of spweb and spsite rather than getting it from "Properties" Thanks Saumil Thakkar

C# Problem with multiple SerialDataRecieved event handlers

Hi all, I'm relatively new to C# and have no formal programming experience so apologies in advance if the way I do things are bad practice etc - I generally implement things in a way which seems logical to me! As a small project I'm making a toy car which can drive itself, the problem I've currently got is reading data from two serial port devices at once. The way I tend to work is to write smaller applications to do one function and get that working before integrating it into a larger application which will pull all the functions together. I've written a "Serial_Port_Communications" class which allows you to pass a serial port object into it and then perform some typical functions: open a port, close it, read data, write data etc. Thats common code across all of my serial devices (they all need to do the same operation so why re-write it?) Then for each device I've got a class which handles the operations and data specific to it: GPS & Compass. Each of those two create instances of the Serial_Port_Communications class. In the GPS & Compass classes, they each have a SerialPort object which has an eventhandler assigned to it for when data is received e.g GPS.datareceived += & Compass.datareceived +=... They each work flawlessly when they run as the mini-applications i.e. I can Parse the GPS data that is received and I can read

Problem registering client side script to interact with AJAX controls

Im using some animationExtenders in my project. The thing is, the objects to be animated are created programmatically, hence i need to also build programmatically the javascript code that will interact with them.It runs properly but, when i interact with these animated controls and the javascript functions are supposed to get to work, i keep getting the usual run-time error saying that the javascript functions are not defined. But, if i check the final html code generated, i can see how all the controls i built programmatically are there ,as well as the script.Tried both RegisterStartupScript and RegisterClientScriptBlock, no luck.Any advice? thanks in advance

Weird Paint Event Problem

I am creating a .net program which requires a rectangle to be drawn on the screen,  the code is triggered by a menu item click, which runs the code:    this->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::PaintForm);   this event draws a rectangle fill, then a rectangle line around it (anybody know how to make that one shape instead of two?) like this: Graphics^ g = this->CreateGraphics(); Pen^ blackPen = gcnew Pen(Color::Black); SolidBrush^ whiteBrush = gcnew SolidBrush(Color::White); Rectangle stage = Rectangle(70, 70, 339, 439); g->DrawRectangle(blackPen, 69, 69, 340, 440); g->FillRectangle(whiteBrush, stage) the code runs fine, but the shape will not appear (the screen won't blit) until I minimize the form, then restore it. I've tried all sorts of things like using e->Graphics-> Instead of the Graphics^ g = this->CreateGraphics();, and nothing seems to fix it. Any help? By the way, I'm fine with receiving code samples in codes other than c++.

Grid view event problem


i call a sql



mydate <30   grid 1 color is red

mydate <45  grid 1 color is blue

mydate <450   grid 1 color is blue

it is apply on grid coloum how do it

how can i load a window1.xaml form from click event fuction of a button

how can i load a window1.xaml form from click event fuction of a button

load window1.xaml from the click event of a button

how can i load window1.xaml from the click event of a button that I created by myaddin to outlook 2003.

event.keyCode problem in Firefox and chrome


Following code is working in IE but not in Firefox and chorme

TextBox1.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('"+Button1.UniqueID+"').click();return false;}} else {return true}; "); 

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend