or
protected void rgMyGrid_PreRender(object sender, EventArgs e) { try { foreach (GridDataItem item in rgMyGrid.MasterTableView.Items) { if (item is GridDataItem) { foreach (GridColumn col in rgMyGrid.Columns) { //Add space to the cell that has null or empty value if (!col.ColumnType.Equals("GridTemplateColumn")) { if (string.IsNullOrEmpty(item[col.UniqueName].Text.Trim()) || item[col.UniqueName].Text.Equals(" ")) { item[col.UniqueName].Text = " "; } } else { #region AllowSpaceInCols switch (col.UniqueName) { case "lblColumn1": Label lblColumn1= item.FindControl("lblColumn1") as Label; if (lblColumn1.Text.Trim().Equals(String.Empty) || lblColumn1.Text.Trim().Equals(" ")) { lblColumn1.Text = " "; } break; case "Column2": Label lblColumn2 = item.FindControl("lblColumn2") as Label; if (lblColumn2 .Text.Trim().Equals(String.Empty) || lblColumn2 .Text.Trim().Equals(" ")) { lblColumn2 .Text = " "; } break; default: break; } #endregion } } } } } catch (Exception ex) { } }<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Message.ascx.cs" Inherits="Elearning.Usecases.UserControl.Message" %><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script><script type="text/javascript"> $(document).ready(function () { setTimeout(function () { $("#<%=MessageContainer.ClientID %>").fadeOut("slow", function () { $("#<%=MessageContainer.ClientID %>").remove(); }); }, 2000); $('.closeImage').click(function () { $(this).parent().hide(); }); });</script><div Class="Message"><asp:Panel ID="MessageContainer" runat="server"> <asp:Image ID="CloseImage" CssClass="closeImage icon" Style="float: right;" runat="server" ImageUrl='<%# HermesControl.GetAppItemRelativeUrl(Elearning.ElearningCommon.Icons.Delete ) %>' /> <asp:Label ID="lblMessage" EnableViewState="false" runat="server" /></asp:Panel></div>
Main page
<telerik:RadAjaxManagerProxy ID="AjaxManagerProxy1" runat="server">
<telerik:AjaxSetting AjaxControlID="imgbtnShowMessagetnSave">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="message1" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="message1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="message1" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManagerProxy>
<include:message ID="message1" runat="server" />
<asp:Button runat="server" ID="btnShowMessage"/>
And if a call show messages, then message show but don´t hide after two second.
Please you know why?
Thanks and sorry for my english
<telerik:RadGrid ID="gvViolation" EnableViewState="false" runat="server" AllowPaging="true" AllowSorting="True" AllowFilteringByColumn="false" GridLines="None" Skin="Sunset" Width="735px" PageSize="3"> <ExportSettings OpenInNewWindow="true" > <Pdf Author="WheelTrack" Creator="WheelTrack" /> </ExportSettings> <MasterTableView AllowMultiColumnSorting="true" TableLayout="Fixed" > <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn> <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn> <PagerStyle Mode="NextPrevAndNumeric" /> <CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true" ShowExportToPdfButton="true" ShowAddNewRecordButton="false" ShowExportToCsvButton="true" /> <Columns> <telerik:GridBoundColumn DataField="Device_Name" HeaderText="Device Name" /> <telerik:GridBoundColumn DataField="Device_Desc" HeaderText="Device Desc" /> <telerik:GridBoundColumn DataField="Rule_Name" HeaderText="Rule Name" /> <telerik:GridBoundColumn DataField="ViolationText" HeaderText="Violation" /> <telerik:GridBoundColumn DataField="Latitude" HeaderText="Latitude" /> <telerik:GridBoundColumn DataField="Longtitude" HeaderText="Longtitude" /> <telerik:GridBoundColumn DataField="UTC_Date" HeaderText="Violation Date" /> <telerik:GridBoundColumn DataField="UTC_Time" HeaderText="Violation Time" /> <telerik:GridBoundColumn DataField="Location_NearBy" HeaderText="Location NearBy" /> </Columns> </MasterTableView> <FilterMenu EnableImageSprites="False"></FilterMenu> <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Sunset"></HeaderContextMenu> <PagerStyle AlwaysVisible="true" Mode="NumericPages"/> <ClientSettings> <ClientEvents OnCommand="gvViolation_Command" /> </ClientSettings></telerik:RadGrid>function Load(sender, args) { sumInput = sender; sender.get_styles().EnabledStyle[0] += "color:Red;"; sender.updateCssClass(); }<telerik:RadGrid ID="grdPlans" runat="server" AutoGenerateColumns="false"> <MasterTableView EditMode="InPlace" ShowFooter="True" TableLayout="Fixed" DataKeyNames="ProjectId"> <Columns> <telerik:GridBoundColumn DataField="ProjectId" HeaderText="Project Id"> <HeaderStyle Width="10%" /> </telerik:GridBoundColumn> <telerik:GridTemplateColumn HeaderText="Jan" DataField="Jan" UniqueName="Jan"> <ItemTemplate> <telerik:RadNumericTextBox ID="txbMonth1" runat="server" Text='<%#Bind("Jan") %>' Width="50px" IncrementSettings-InterceptArrowKeys="true" IncrementSettings-InterceptMouseWheel="true" NumberFormat-DecimalDigits="1" MinValue="0" MaxValue="150"> <ClientEvents OnBlur="Blur1" OnFocus="Focus1" /> </telerik:RadNumericTextBox> </ItemTemplate> <FooterTemplate> <telerik:RadNumericTextBox ID="txbTotal1" runat="server" ReadOnly="true" NumberFormat-DecimalDigits="1" Width="50px"> <ClientEvents OnLoad="Load" /> </telerik:RadNumericTextBox> </FooterTemplate> </telerik:GridTemplateColumn>this._displayElement.style.borderRightWidth=parseInt($telerik.getComputedStyle(this._displayElement,"borderRightWidth",""))+parseInt($telerik.getComputedStyle(this._textBoxElement,"borderRightWidth",""))+"px";<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> <style type="text/css"> .wthrTitle { font-family: Tahoma; font-size: 14px; width: 370px; color: White; background: blue; border-top: 1px solid navy; text-align: center; } .wthrContainer { width: 74px; text-align: center; border: 1px; float: left; } .wthrDayTitle { font-family: Tahoma; font-size: 14px; width: 100%; color: White; background: blue; border-bottom: 1px solid navy; border-top: 1px solid navy; } .wthrForcast { font-family: Tahoma; font-size: 12px; color: blue; } .wthrTemp { font-family: Tahoma; font-size: 10px; color: blue; } .wthrClear { clear: left; } </style><div class="wthrTitle"><asp:Label ID="descriptionLabel" runat="server" Text='' /></div><telerik:RadListView ID="weatherRadListView" runat="server"> <ItemTemplate> <div class="wthrContainer"> <div class="wthrDayTitle"><asp:Label ID="dayLabel" runat="server" Text='<%# Eval("DayName") %>' /></div><br /> <asp:Image ID="forcastImage" runat="server" ImageUrl='<%# Eval("ImageUrl") %>' /><br /> <asp:Label ID="forcastLabel" runat="server" Text='<%# Eval("Forcast") %>' CssClass="wthrForcast" /><br /> <div class="wthrForcast"><asp:Label ID="highLabel" runat="server" Text='<%# Eval("High") %>' />° - <asp:Label ID="lowLabel" runat="server" Text='<%# Eval("Low") %>' />°</div><br /> </div> </ItemTemplate></telerik:RadListView><br class="wthrClear" /><asp:HiddenField ID="zipcodeHidden" runat="server" Value="49333" />// By Phil Huhn 2012-01-08
using System;
using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;//using System.Xml;using System.Xml.Linq;using System.Net;//namespace Telerik.UserControls{ public partial class YahooWeather : System.Web.UI.UserControl { // // ------------------------------------------------------------------------ // Properties // ZipCode // #region "Properties" // /// <summary> /// External way to pass values to user control /// </summary> /// <value></value> /// <returns></returns> /// <remarks></remarks> public string ZipCode { get { return zipcodeHidden.Value; } set { zipcodeHidden.Value = value; } } // #endregion // /// <summary> /// call during each postback /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks></remarks> protected void Page_Load(object sender, EventArgs e) { GetWeather(ZipCode); } // /// <summary> /// Get weather from yahoo /// </summary> /// <param name="zipCode"></param> /// <remarks></remarks> protected void GetWeather(string zipCode) { try { XDocument xmlData = XDocument.Load("http://xml.weather.yahoo.com/forecastrss/" + zipCode + "_f.xml"); // List<WeatherItem> _list = new List<WeatherItem>(); string _description = null; System.DateTime _date; //...<channel> foreach (XElement _row in xmlData.Root.Elements("channel")) { foreach (XElement _field in _row.Elements()) { //<title>Yahoo! Weather - Any Town</title> //<link></link> //<description>Yahoo! Weather for Any Town</description> if ((_field.Name.ToString() == "description")) { // cherry pick the desired data at this level. _description = _field.Value; descriptionLabel.Text = _description; } //<language>en-us</language> //<lastBuildDate>Sat, 07 Jan 2012 10:51 am EST</lastBuildDate> if ((_field.Name.ToString() == "lastBuildDate")) { string _dateString = _field.Value.Substring(5); _date = DateTime.Parse(_dateString.Substring(0, _dateString.Length - 4)); descriptionLabel.Text = _description + " at " + _date.ToShortTimeString(); } //<ttl>60</ttl> //<yweather:location city="Any Town" region="MI" country="US"/> //<yweather:units temperature="F" distance="mi" pressure="in" speed="mph"/> //<yweather:wind chill="35" direction="310" speed="14"/> //<yweather:atmosphere humidity="65" visibility="10" pressure="29.89" rising="1"/> //<yweather:astronomy sunrise="8:02 am" sunset="5:17 pm"/> //<image> //<item> if (_field.Name.ToString() == "item") { foreach (XElement _itm in _field.Elements()) { if (_itm.Name.LocalName == "forecast") { WeatherItem _wi = new WeatherItem(); _wi.YahooForcast(_itm); _list.Add(_wi); } } } } } if (_list.Count > 0) { _list[0].DayName = "Today"; } weatherRadListView.DataSource = _list; weatherRadListView.DataBind(); } catch (Exception e) { int _i = 1; } } // }}public class WeatherItem{ public string DayName { get; set; } public System.DateTime Day { get; set; } public int Low { get; set; } public int High { get; set; } public string Forcast { get; set; } public string Code { get; set; } public string ImageUrl { get; set; } public string LocalImageUrl { get; set; } protected string LocalImagePath = "../Images/Weather/"; // public WeatherItem() { } // public WeatherItem(string localImagePath) { LocalImagePath = localImagePath; } // // <yweather:forecast day="Sun" date="8 Jan 2012" // low="28" high="37" text="Partly Cloudy" code="30"/> // public void YahooForcast(XElement forcastItem) { DayName = forcastItem.Attribute("day").Value; Day = Convert.ToDateTime(forcastItem.Attribute("date").Value); Low = Convert.ToInt32(forcastItem.Attribute("low").Value); High = Convert.ToInt32(forcastItem.Attribute("high").Value); Forcast = forcastItem.Attribute("text").Value; Code = forcastItem.Attribute("code").Value; ImageUrl = "http://l.yimg.com/a/i/us/we/52/" + Code + ".gif"; LocalImageUrl = LocalImagePath + Code + ".gif"; }}' By Phil Huhn 2012-01-08Option Strict OnOption Explicit On'Imports System.XmlImports System.Net'Public Class YahooWeather Inherits System.Web.UI.UserControl ' ' ------------------------------------------------------------------------ ' Properties ' ZipCode '#Region "Properties" ' ''' <summary> ''' External way to pass values to user control ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Property ZipCode() As String Get Return zipcodeHidden.Value End Get Set(ByVal value As String) zipcodeHidden.Value = value End Set End Property ' #End Region ' ''' <summary> ''' call during each postback ''' </summary> ''' <param name="sender"></param> ''' <param name="e"></param> ''' <remarks></remarks> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load GetWeather(ZipCode) End Sub ' ''' <summary> ''' Get weather from yahoo ''' </summary> ''' <param name="zipCode"></param> ''' <remarks></remarks> Protected Sub GetWeather(zipCode As String) Try Dim xmlData As Linq.XDocument = _ XDocument.Load("http://xml.weather.yahoo.com/forecastrss/" & zipCode & "_f.xml") ' Dim _list As New List(Of WeatherItem) Dim _description As String = Nothing Dim _date As Date = Nothing For Each _row As XElement In xmlData.Root.Elements("channel") '...<channel> For Each _field As XElement In _row.Elements '<title>Yahoo! Weather - Any Town</title> '<link></link> '<description>Yahoo! Weather for Any Town</description> If (_field.Name.ToString() = "description") Then ' cherry pick the desired data at this level. _description = _field.Value descriptionLabel.Text = _description End If '<language>en-us</language> '<lastBuildDate>Sat, 07 Jan 2012 10:51 am EST</lastBuildDate> If (_field.Name.ToString() = "lastBuildDate") Then Dim _dateString As String = _field.Value.Substring(5) _date = DateTime.Parse(_dateString.Substring(0, _dateString.Length - 4)) descriptionLabel.Text = _description & " at " & _date.ToShortTimeString End If '<ttl>60</ttl> '<yweather:location city="Any Town" region="MI" country="US"/> '<yweather:units temperature="F" distance="mi" pressure="in" speed="mph"/> '<yweather:wind chill="35" direction="310" speed="14"/> '<yweather:atmosphere humidity="65" visibility="10" pressure="29.89" rising="1"/> '<yweather:astronomy sunrise="8:02 am" sunset="5:17 pm"/> '<image> '<item> If _field.Name.ToString() = "item" Then For Each _itm As XElement In _field.Elements If _itm.Name.LocalName = "forecast" Then Dim _wi As New WeatherItem() _wi.YahooForcast(_itm) _list.Add(_wi) End If Next End If Next Next If _list.Count > 0 Then _list(0).DayName = "Today" End If weatherRadListView.DataSource = _list weatherRadListView.DataBind() Catch e As Exception Dim _i As Integer = 1 End Try End Sub 'End ClassPublic Class WeatherItem Public Property DayName() As String Public Property Day() As Date Public Property Low() As Integer Public Property High() As Integer Public Property Forcast() As String Public Property Code() As String Public Property ImageUrl() As String Public Property LocalImageUrl() As String Protected LocalImagePath As String = "../Images/Weather/" ' Public Sub New() End Sub ' Public Sub New(localImagePath As String) localImagePath = localImagePath End Sub ' ' <yweather:forecast day="Sun" date="8 Jan 2012" ' low="28" high="37" text="Partly Cloudy" code="30"/> ' Public Sub YahooForcast(forcastItem As XElement) DayName = forcastItem.Attribute("day").Value Day = CDate(forcastItem.Attribute("date").Value) Low = CInt(forcastItem.Attribute("low").Value) High = CInt(forcastItem.Attribute("high").Value) Forcast = forcastItem.Attribute("text").Value Code = forcastItem.Attribute("code").Value ImageUrl = "http://l.yimg.com/a/i/us/we/52/" & Code & ".gif" LocalImageUrl = LocalImagePath & Code & ".gif" End SubEnd Class