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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Prevent mousedown raise in disabled part of control which is outside control boundary

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


I have a control that is located onto a window in my example. that control contains something that is shown, but the user may not be able to click onto the area (here red colored) to select it. Only by clicking on the black part should select the control.
I disabled the red part, but still the mousedown is fired in the control. I would expect that the mousedown would be raised in the background of the window and not in the control.
Event when the Red part is made transparent, the event is fired inside the control (BUG???)

Is there a way to prevent that when the red part is clicked, the control raises the mousedown.
I simplified the example.

<Window x:Class="MainWindow"
    Title="MainWindow" Height="350" Width="525" MouseDown="Background_MouseDown">
  <Grid  HorizontalAlignment="Left" VerticalAlignment="Top" >
    <Canvas MouseDown="Control_mouseDown" Width="100" Height="100" HorizontalAlignment="Left" VerticalAlignment="Top"  Background="Black" >

View Complete Post

More Related Resource Links

Choosing Between a User Control or Web Part for SharePoint

SharePoint will only display Web Parts on a page. However, there are publicly available shims that allow you to write user controls and have them be displayed as a Web Part. From SharePoint's point of view, the shim is a Web Part. From the point of view of the user control, the shim is simply a control in .NET that is including the user control

ASP.NET DropDownList Web Control, Part 1

Anybody with much experience in ASP has written an include file function for populating the contents of a SELECT dropdown list with entries from a database. Some of the more advanced users have even gone so far as to add caching to their function to reduce database hits for these rarely changing menu options. Naturally, these same techniques are going to be used with ASP.NET, but with a new programming object model. ASP.NET provides a web control, the DropDownList, which can be used for the same purposes as our custom built SELECT tag from Classic ASP.

How to Fire events on SharePoint DateTime Control in visual web part

Hi All, I am working on visual webpart of SharePoint 2010. I am using a <SharePoint:DateTimeControl> i m trying  to fire OnDateChanged event on it. I am not getting the Appropriate way to create the event. please help me out!!!!   void ToDate_OnDateChanged(object sender, EventArgs e)         {                         if (ToDate != null)             {                 DateTime min = Convert.ToDateTime(FromDate.SelectedDate.ToString());                 DateTime max = Convert.ToDateTime(ToDate.SelectedDate.ToString());                 int noofdays = Convert.ToInt32((max - min).TotalDays);                 txtNoOfDays.Text = noofdays.ToString();             }         }    <SharePoint:DateTimeControl runat="server" Calendar="Gregorian"  

Closer look at GridView control (Part 1)

Normal 0 false false false MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} Normal 0 false false false MicrosoftInternetExplorer4 Normal 0 false false false MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} You may wonder that why I have chosen topic on GridView control, when there are lot of material available on internet for GridView. But this article focus on closer look on GridView control,

ObjectDataSource Control Disabled/not appearing in Toobox for Visual Studio 2010 SharePoint Project

  1. I've created a SharePoint Project in Visual Studio 2010.
  2. Added Visual webPart .
  3. In the usercontrol of the webpart in trying to add ObjectDataSource control, but this control is not availble in Tool box under Data tab. it appears only if i right click on datatab and select "Show All", but still the ObjectDataSource Control is Disabled and even i cannot drag and drop it on the Webpart.
  4. Also i've created a sample Business Class, with all the mandatory attribute like





User Control Web Part - The type initializer for 'IBM.Data.DB2.DB2Connection' threw an exception.



I need help, in our SharePoint 2007 project we have created Web Part using VS 2005 & .Net 2.0, User Control. In the user control for one of the drop down list box databinding method we are using data from IBM DB2. It works fine on our local machine, but after Web Part deployment if i open the page then the Drop Down List is empty. I checked the log in the event viewer. I found the following error message in the vent viewer -

The type initializer for 'IBM.Data.DB2.DB2Connection' threw an exception.


Detail Error Message -

An unhandled exception occurred and the process was terminated.

Application ID: /LM/W3SVC/2076212728/Root

Process ID: 26880

Exception: System.TypeInitializationException

Message: The type initializer for 'IBM.Data.DB2.DB2Connection' threw an exception.

StackTrace: at IBM.Data.DB2.DB2Connection.Finalize()

InnerException: System.InvalidOperationException

Message: SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7, tokens 9.1.1.DEF.2, SOFTWARE\IBM\DB2\InstalledCopies

StackTrace: at IBM.Data.DB2.y.f.a()

at IBM.Data.DB2.DB2ConnPool.g()

at IBM.Data.DB2.DB2ConnPool..ctor()

at IBM.Data.DB2.DB2Connection..cctor()

For more information, see Help and Support Center at h

Ajax, Smart Parts(web part w/ ajax support), User Control, and a GridView


So I am playing around with a user control that I created that adds some functionality to a SPList. I have scoured the web looking for a way to get a web part that had a gridview with custom buttons that is bound to certain Items in a sharepoint list. I found Smart Parts and created an Ajax enabled User Control. the problem is that the label is updating but the gridview is not. and on a site note how can I format the Time on Board column to not include milliseconds(the fields are showing up like '1.02:48:31.8633636') i just want 1.02:48 and maybe the 31:

here is my ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AlertControlWebPart.ascx.cs"
  Inherits="AlertControlWebPart.AlertControlWebPart, AlertControlWebPart, Version=, Culture=neutral, PublicKeyToke

Get context to a control in web part from visual user control


I have a Visual Web Part (lets call it "ABCWebPart").

I'm attempting to create a connection to another web part which means I have to create the ConnectionProvider in the WebPart class (ABCWebPart.cs).

The value I want to set in my AJAX provider interface is a control I created in my visual user control (ABCWebPartUserControl.ascx).

How do I get the context of the TextBox control from my Visual user Control in order to assign it's value into the AJAX provider interface?


Thanks in advance,

- Eric

Create asp Hyperlink control dynamically in web part


Hi all,

I am now writing a customized Web Part to list out all the documents in a document library and I use an ASP 'Hyperlink' control for each document item.

The problem is, the number of Hyperlink controls depends on the number of documents and should be created dynamically. My approach is the hyperlinks will be generated after the user clicked a button in the web part.

So I would like to ask how can I generate those Hyperlinks dynamically at run time(the user clicks the web part button)?


Visual Web part with embedded User Control, fields are null


I have a legacy ASP.Net application that consisted of a series of ascx user controls which I am attempting to convert into visual web parts.  

I have wrapped each ascx in its own visual webpart and deployed to my site. Within my site I am able to add some of these to my pages and they render properly.

The ones that I am having difficulty with are those ascx user controls that have a child reference to other custom user controls.

For example I have CustomerinfoUserControl.ascx that has many fields within the control, but one is also a custom user control to select the date called DatePicker2UserControl.asx

Here is the declaration within CustomerInfoUserControl  and usage …



Prevent double-click on button control



I've read several posts on this subject, but most solutions refer to using http://www.metabuilders.com/Tools/OneClick.aspx or to using javascript to disable the button (after the first click).  Both of these solutions would work, but I was hoping for some basic server code that uses the standard button control, and that I could re-use on various forms to prevent double-clicks.  Or if there are any good articles or suggestions on this that you could direct me to view I would appreciate it.  Thanks for your help!

"This control is currently disabled..." Most Library-->Documents ribbon actions are greyed


This started when I just needed to delete a document, I noticed most of the actions on the ribbon for Library-->Documents were greyed out.  The only thing that is not greyed is Upload document.  I have tried with multiple administrator accounts, installed office client on the server, I have tried from multiple clients and get the same thing.  Windows 7 and Office 2010 are on the clients I have tried.

Is it possible I may have missed an explicit permission that even an administrator account (domain admin + SP site collaction/farm admin) does not have?

How can I prevent the pop up window from disappearing? (HoverMenuExtender AJAX control)


Hi all,

I have a GridView (insde a UpdatePanel with a Timer control) which is refreshed every 3 seconds and one of its fields (a TextBox) is "linked" to a HoverMenuExtender. It works great to display the Multline Textbox results but when the next refresh timer interval comes the TextBox control is re-populated with the new data and the user does not have the time to read its content.

I am not sure if there is a way to maintain the content after each refresh (as long as I don't move the mouse of course).
Here is part of my code:

                         <asp:TemplateField HeaderText="Last Output" >

                              <asp:TextBox ID="txtBoxComments" runat="server" MaxLength="1000" ReadOnly="true" Rows="1"
			 Text='<%# Eval("LastOutput") %>' TextMode="MultiLine" style="OVERFLOW:hidden" />
                                <ajax:HoverMenuExtender ID="HoverMenuExtender1" runat="server"

Rewrite URL causes disabled menu of buttons in Seadragon control


Hi all,

I implement IHttpModule to rewrite url address. Other images, css, js work well except zoom images control on Seadragon.

Anybody please helps. I am really appreciate.


TCP Connection Error with Custom Control Web Part


Hello all,

We have a custom web part based on a user control that queries a database cluster. When the connection to the database is made, we regularly experience the error below and have had to create a work-around in the code to retry the connection.  We have 3 environments - development, staging and production; the error only occurs in production.  The difference in the production environment is it is a farm with 3 WFEs and a SQL cluster, where development and staging are single machine instances.  All are MOSS 2007 & SQL Server 2008.

We cannot find what is causing this issue and I'm hoping someone else has experienced a similar problem and knows the cause.

This is the error that occurs frequently when the query is executed:

System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)

at System.Data.SqlClient.TdsParserStateObject.WriteSni()

at System.Data.SqlClient.TdsParserStateObject.ExecuteFlush()

at System.Data.SqlClient.TdsParser

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