Can't use BackgroundImage property on a Button - c#

I'm trying to set an image as button background as follows:
button.BackgroundImage = Properties.Resources.blue;
But I get an error that says:
'Button does not contain a definition for 'backgroundImage' and no accessible extention method 'BackgroundImagew accepting a first argument of type 'Button' could be found (are you missing a using directive or an assembly reference?)

button.Background = Brushes.Blue;
Is this the result you are trying to gather

Related

open a PDF in windows Form

I am trying to load a pdf into a axAcroPDF using this method that I found here. but there isn't a this.axAcroPDF.LoadFile() there. The error message that I get says:
"AxacroPDFLib.AxacroPDF doesn't contain a defection for 'LoadFile' and
no Extension method excepting first method of a type
AxacroPDFLib.AxacroPDF could be found (Are you missing a using
directive or an assembly reference?"
So I double checked and there are Acrobat , AcroPDFLib, AxAcroPDFLib Referances in the WPF and user control.
Next I goggled this again and found this on YouTube that uses this.axAcroPDF.src =path; however I do not this option either. Please tell me if they have changed the LoadFile(path) to something else, or if there is a reference that I am missing?
axAcroPDF1.LoadFile(PDFPath.ToString());
axAcroPDF1.setShowToolbar(false); //disable pdf toolbar.
axAcroPDF1.Enabled = true;
Another solution is to set the src property of your Axacro control.

DotNetNuke DDRMenu set NodeSelector in code behind

I'm using DDRMenu in DotNetNuke to select a menu node from my site structure and display only a subnode in a specific navigation in my template
<%# Register TagPrefix="dnn" TagName="MENU" Src="~/DesktopModules/DDRMenu/Menu.ascx" %>
<dnn:MENU ID="MenuFooter" MenuStyle="MenuFooter" IncludeHidden="true" NodeSelector="FooterNavigation,0,1" runat="server" ></dnn:MENU>
Now I want to be able to set the NodeSelector attribute in the code behind file, because I want to be able to dynamically set the value on Page_Load
// load footer navigation node from a config file
protected void Page_Load(object sender, EventArgs e)
{
var footerNode = Config.Instance.Navigation.FooterNode;
MenuFooter.NodeSelector = footerNode + ",0,1";
}
But this doesn't work, as there is no NodeSelector attribute on System.Web.UI.UserControl.
Error 'System.Web.UI.UserControl' does not contain a definition for 'NodeSelector' and no extension method 'NodeSelector' accepting a first argument of type 'System.Web.UI.UserControl' could be found (are you missing a using directive or an assembly reference?) C:\Projects\eWolf2012\dev\DNN\Portals_default\Skins\JWEwolfSkin2012\Simple.ascx.cs 141 24 JWEwolfSkin2012
Is there any way to achieve this?
Kind regards
Usually the Menu.ascx in DDRMenu inherits from the DDRMenu SkinObject:
<%# Control Language="C#" AutoEventWireup="false" EnableViewState="false" Inherits="DotNetNuke.Web.DDRMenu.SkinObject" %>
Since you are talking about changing the code behind I guess that you are using a custom control that embeds the Menu.ascx. In which case you should be able to access the NodeSelector property since it exists in the SkinObject class.
What I am suspecting is happening is that your control type is not loaded correctly by the designer, and that it falls back on the UserControl type which doesn't have the NodeSelector property.
Try the following:
Include the DDRMenu assembly in your current project (because it won't load the type if it doesn't find the assembly), then rewrite the include to kick the designer into motion. I'm pretty confident this is the cause of the problem, but if not:
Fiddle with your src attribute and check in the *.designer file what type is defined.
Define it manually in your code-behind file instead of letting the designer do it.

Adding a home button to your wpf browser

I can't seem to get the Home button in my wpf web browser to work. Do you guys have any idea?
I have tried:
WebBrowser1.GoHome();
But I'm reciving:
'System.Windows.Controls.WebBrowser' does not contain a definition for 'GoHome' and no extension method 'GoHome' accepting a first argument of type 'System.Windows.Controls.WebBrowser' could be found (are you missing a using directive or an assembly reference?)
However, other commands are working just fine, for example:
WebBrowser1.GoBack();
Try to assign a set URL to the button/save the location as a file. Consider it more like a bookmark:
string input = Microsoft.VisualBasic.Interaction.InputBox("Please set your home page", "Settings");
WebBrowser1.Navigate(Registry.GetValue(#"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Start Page", "").ToString());
That will work for IE, for any other browser it gets...complicated...

C# How to add an image on button array buttons

How can I add an image on buttons of button array ?
Button[] mybuttons = new Button[] {Button1,Button2}; //My button array
mybuttons[1].image=new Bitmap("Click.jpg"); ///Gives Error
'System.Web.UI.WebControls.Button' does not contain a definition for 'Image' and no extension method 'Image' accepting a first argument of type 'System.Web.UI.WebControls.Button' could be found (are you missing a using directive or an assembly reference?)
C# is case sensitive. Also, you need to use an ImageButton and give it an ImageUrl, not a Button. The web control Button does not have an Image property.

How can you get a xaml element using C#?

I have a xaml page samplePage.xaml and its corresponding .cs file samplePage.xaml.cs. In this page there is a textBox textBox1.
Now I create an instance of the page:
PhoneApp1.samplePage s = new PhoneApp1.samplePage();
and after that, I would like to set the value in the text box by calling:
s.textBox1.Text = "whatever"
but it turns out there is an error message saying
'PhoneApp1.samplePage' does not contain a definition for 'textBox1'
and no extension method 'textBox1' accepting a first argument of type
PhoneApp1.samplePage' could be found (are you missing a using
directive or an assembly reference?)
I would like to know how to get the xaml element using C# code?
You textbox is probably private or protected. Add a wrapper in your page to expose the textbox, something like :
public TextBox TextBox1
{
get
{
return this.textBox1;
}
}
(mind the case)
Then just use the property from anywhere you want: s.TextBox1.Text = "whatever";
Good question, you'll need to use XamlReader.Load to load your page/control at runtime, then you'll be able to access the controls within it:
http://msdn.microsoft.com/en-us/library/cc189076(v=vs.95).aspx#using_xamlreaderload
http://blogs.silverlight.net/blogs/msnow/archive/2008/10/09/silverlight-tip-of-the-day-60-how-to-load-a-control-straight-from-xaml.aspx

Categories