I have a MVC3 WebGrid in my View.I want to display a tooltip when the mouse hovers over any row, displaying information coming from the server. I have already seen this link:
Show a tooltip with more info when mousover a MVC3 Razor WebGrid row
My point is,how will I get the ID of the row on mouseover event,because the information coming from the server will be based on row ID or maybe count. Also, in this link:
http://www.lullabot.com/files/bt/bt-latest/DEMO/index.html
you need a certain Selector to show the tooltip.So how can I assign a class to each row of WebGrid so I can display the tooltip?
Here is how I did it. Because of the limited nature of the default WebGrid, you are left with a few options... I needed this to work with IE6 and could NOT find a suitable jQuery plugin that would work in all browser, so I opted for option 1. Warning: It's a bit dirty
1 - Roll your own HtmlHelper
2 - Use a third-party alternative to WebGrid
3 - Use a jQuery plugin
HtmlHelpers.cs
/// <summary>
/// This class contains various methods for supplementing the usage of html within the Razor view pages
/// </summary>
public static class HtmlHelpers
{
/// <summary>
/// This method truncates a string to a given length for display within a WebGrid or elsewhere as a tooltip
/// </summary>
/// <param name="helper">Generic parameter needed to recognize HtmlHelper syntax</param>
/// <param name="input">This is the string to truncate</param>
/// <param name="length">The length of the string to truncate to</param>
/// <returns>Html representing a tooltip, if needed</returns>
public static IHtmlString ToolTip(this HtmlHelper helper, String input, int length)
{
if (input.Length <= length)
return new MvcHtmlString(input);
else
return new MvcHtmlString(String.Format("<span title=\"{2}\">{0}{1}</span>", input.Substring(0, length), "...", input));
}
}
YourView.cshtml
grid.Column(columnName: "Detail", header: "Description", format: #<text>#Html.Truncate((string)item.Detail,50)</text>),
Related
Related to: YouTube iframe embed - full screen
Is it possible to pass the allowFullscreen without iframe? I'm developing for Xamarin and I'm using a WebView that simply opens the embed url itself, I don't see the need for iframe here, but I'd like to have the fullscreen possibility...
To enable full-screen support in a Xamarin Forms WebView for Android, you can create custom fullScreen_webview to do.
public class FullScreenEnabledWebView : WebView
{
/// <summary>
/// Bindable property for <see cref="EnterFullScreenCommand"/>.
/// </summary>
public static readonly BindableProperty EnterFullScreenCommandProperty =
BindableProperty.Create(
nameof(EnterFullScreenCommand),
typeof(ICommand),
typeof(FullScreenEnabledWebView),
defaultValue: new Command(async (view) => await DefaultEnterAsync((View)view)));
/// <summary>
/// Bindable property for <see cref="ExitFullScreenCommand"/>.
/// </summary>
public static readonly BindableProperty ExitFullScreenCommandProperty =
BindableProperty.Create(
nameof(ExitFullScreenCommand),
typeof(ICommand),
typeof(FullScreenEnabledWebView),
defaultValue: new Command(async (view) => await DefaultExitAsync()));
/// <summary>
/// Gets or sets the command executed when the web view content requests entering full-screen.
/// The command is passed a <see cref="View"/> containing the content to display.
/// The default command displays the content as a modal page.
/// </summary>
public ICommand EnterFullScreenCommand
{
get => (ICommand)GetValue(EnterFullScreenCommandProperty);
set => SetValue(EnterFullScreenCommandProperty, value);
}
/// <summary>
/// Gets or sets the command executed when the web view content requests exiting full-screen.
/// The command is passed no parameters.
/// The default command pops a modal page off the navigation stack.
/// </summary>
public ICommand ExitFullScreenCommand
{
get => (ICommand)GetValue(ExitFullScreenCommandProperty);
set => SetValue(ExitFullScreenCommandProperty, value);
}
private static async Task DefaultEnterAsync(View view)
{
var page = new ContentPage
{
Content = view
};
await Application.Current.MainPage.Navigation.PushModalAsync(page);
}
private static async Task DefaultExitAsync()
{
await Application.Current.MainPage.Navigation.PopModalAsync();
}
}
More detailed info about enable full-screen support in xamarin.android Webview, you can take a look this sample:
https://github.com/microsoft/CSSClientAppsXamarinSampleCode/tree/main/FullScreenWebView
You can click Iframe in the red box at the bottom right to full-screen, the screenshot:
I've just started to test my app on android tablet and have found a strange bug:
I wanted to being masterpage enabled only when my main page is opened.
So I created Custom NavigationPage and overrided methods:
/// <summary>
/// Отключение бокового меню при добавлении на главный экран новых страниц
/// </summary>
/// <param name="child"></param>
protected override void OnChildAdded(Element child)
{
base.OnChildAdded(child);
if (this.Navigation.NavigationStack.Count > 1)
App.detailPage.IsGestureEnabled = false;
}
/// <summary>
/// Включение бокового меню при наличии только одной страницы на главном экране
/// </summary>
/// <param name="child"></param>
protected override void OnChildRemoved(Element child)
{
base.OnChildRemoved(child);
if (this.Navigation.NavigationStack.Count < 2)
App.detailPage.IsGestureEnabled = true;
}
here is my landscape main page:
When I push some pages to my NavigationPage, the master page disappears:
and after that, when I return on my main page, the masterpage is still not available:
At least I need to show my MasterPage on my MainPage, and it would be perfect if somebody tell me, how to hide masterpage to the left and use it with swipe gestures, like on phones. Thanks in advance.
By the way, I've found the answer for my issue :)
Right now, I end up with adding behavior for Tablet idiom in my MasterPage.
Constructor's code:
public MasterDetailPage1()
{
InitializeComponent();
/// Some coding
if (Device.Idiom == TargetIdiom.Tablet)
MasterBehavior = MasterBehavior.Popover;
/// Some coding
}
Hope that helps somebody.
Is there a way to increase the default font size of the RadMessageBox for the whole application without having to create a custom theme?
If not, how to just increase the font on the default theme in Visual Style Builder? I tried just increasing the label and button font sizes, but the style builder reset the whole form that hosts the message box to look very plain and cutting the text of the label (see attached screenshot).
Thank you.
It is possible to customize the font for all RadMessageBoxes within an application.
Implement a method ('SetTelerikControlStyles') which is called before any form and/or RadMessageBox is created. You only need to call this method once!
Add the following lines of code in the created method of step 1:
RadMessageBox.Instance.FormElement.TitleBar.Font = new Font("Calibri", 25f);
RadMessageBox.Instance.Controls["radLabel1"].Font = new Font("Calibri", 50f, FontStyle.Regular);
The FormElement.TitleBar.Font, as the name already reveals, is the title bar of the RadMessageBox.
Telerik is using dynamic named controls, so in this case radLabel1 represents the RadMessageBox text area.
Complete Program.cs sample:
using System;
using System.Drawing;
using System.Windows.Forms;
using Telerik.WinControls;
namespace WindowsFormsApplication
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
SetTelerikControlStyles();
Application.Run(new Form1());
}
private static void SetTelerikControlStyles()
{
RadMessageBox.Instance.FormElement.TitleBar.Font = new Font("Calibri", 25f);
// I added this additional check for safety, if Telerik modifies the name of the control.
if (RadMessageBox.Instance.Controls.ContainsKey("radLabel1"))
{
RadMessageBox.Instance.Controls["radLabel1"].Font = new Font("Calibri", 50f, FontStyle.Regular);
}
}
}
}
I need to Hide the overflow icon in Hardware menu button in my Xamarin Android app(three dots) - refer the screen shot.
How do i do this?
I did not find the overflow icon in my nexus 6, but I would like give you some suggestions:
For the xamarin android project the Android.App.Activity is different between the Activity of Java android.
We can find the source code of the Android.App.Activity when the activity create a menu it will call the following function:
// Summary:
// Initialize the contents of the Activity's standard options menu.
//
// Parameters:
// menu:
// The options menu in which you place your items.
//
// Returns:
// To be added.
//
// Remarks:
// ///
// Initialize the contents of the Activity's standard options menu. You /// should
// place your menu items in to menu. /// ///
// ///
// This is only called once, the first time the options menu is /// displayed. To
// update the menu every time it is displayed, see /// Android.App.Activity.OnPrepareOptionsMenu(Android.Views.IMenu).
// /// ///
// ///
// The default implementation populates the menu with standard system /// menu items.
// These are placed in the Android.Views.Menu.CATEGORY_SYSTEM group so that ///
// they will be correctly ordered with application-defined menu items. /// Deriving
// classes should always call through to the base implementation. /// ///
// ///
// You can safely hold on to menu (and any items created /// from it), making modifications
// to it as desired, until the next /// time onCreateOptionsMenu() is called. ///
// ///
// ///
// When you add items to the menu, you can implement the Activity's /// Android.App.Activity.OnOptionsItemSelected(Android.Views.IMenuItem)
// method to handle them there.
// ///
// /// /// [Android Documentation] /// ///
// ///
[Register("onCreateOptionsMenu", "(Landroid/view/Menu;)Z", "GetOnCreateOptionsMenu_Landroid_view_Menu_Handler")]
public virtual bool OnCreateOptionsMenu(IMenu menu);
This onCreateOptionsMenu function will be called as default. Xamarin android encapsulates onCreateOptionsMenu function of Java Android. I think you can override the function in you MainActivity as follows:
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
}
public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
{
return false;
}
}
The menu should be created as default.
That depends on a Particular Device and Its OS , some of them create options menu like your device but some on right corner of the top
Update:
private string _catalogIconImageUrl = "http://hostname/images/favicon.ico";
[WebBrowsableAttribute(false),
Category("HIDDEN"),
Personalizable(PersonalizationScope.User),
WebDisplayName("Catalog Icon Image url"),
WebDescription("Something")]
public string CatalogIconImageUrl
{
get
{
return _catalogIconImageUrl;
}
set
{
_catalogIconImageUrl = value;
}
}
with the above code, it does not show the image and also when i click on edit the webpart i still able to see the catalogIconImageUrl prop in edit mode
Update end
I've declared the property CatalogIconImageURL in the .Webpart file as follows:-
</property>
<property name="CatalogIconImageUrl" type="string">images/company/companylogo.jpg</property> //sample path...
</properties>
if I click on the Advanced Web Part Gallery as shown below in the screen shot, i able to see that property in editable so my question is, is there a way i can hide this property when user edit the web part? "Catalog Icon Image URL"
You can set the WebBrowseable or Browseable attribute to false
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webbrowsableattribute.aspx
http://msdn.microsoft.com/en-us/library/system.componentmodel.browsableattribute.browsable.aspx
Update:
It is also marked as virtual. This property is a OOTB property in WEb Part class. See here:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webpart.catalogiconimageurl.aspx
You should override this property and then set the above attribute to false
/// <summary>
/// Catalog Icon
/// </summary>
[Category("Properties")]
[DefaultValue("")]
[Personalizable(PersonalizationScope.Shared)]
[WebDisplayName("Catalog icon image URL:")]
[WebDescription("Enter the WebPart title.")]
[XmlElement(ElementName = "CatalogIconImageUrl")]
[WebBrowsable(false)]
public override string CatalogIconImageUrl
{
}