.RadGrid_MailMerlin .rgAltRow
{
background
:
#ededed
;
}
RadToolBarButton rtb = new RadToolBarButton();
rtb.Group = sGroup;
rtb.CheckOnClick =
true;
rtb.Checked =
false;
rtb.PostBack =
true;
rtb.ImageUrl = sImageUrl;
rtb.Value = sValue;
rtb.ToolTip = sToolTip;
I add the rtb object, actually more than one, to my RadToolBar.
They all appear correctly in my UI.
However as soon as I mouse over them I get an exception.
I noticed the rendered html is different from an in-line RadToolBarButton.
The dynamically created buttons don't have _item["object Object"] or _itemTypeName["Telerik.Web.UI.RadToolBarButton"] attributes.
What am I missing?
TIA
Public Sub subAddNewPicture(ByVal FileUploader As FileUpload, ByVal strPictureName AsString, ByVal strImgFolder As String)
Dim strImageFolderPath As String
Dim strImagePath As String
Try
' Construct saving path
strImageFolderPath = Path.Combine(Request.PhysicalApplicationPath, strImgFolder)
strImagePath = Path.Combine(strImageFolderPath, strPictureName)
' Upload image this part is not as fit
FileUploader.PostedFile.SaveAs(strImagePath)
FileUploader.PostedFile.InputStream.Dispose()
FileUploader.Dispose()Catch ex As Exception
'Throw ex
End Try
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) HandlesButton2.Click
Dim tamano_fotoP As Integer
Dim tamano_fotoG As Integer
tamano_fotoP = 235
tamano_fotoG = 649
Try
Dim strGuid As String = ""
Dim strPicExtension As String = ""
Dim strFileName As String = ""
If PhotoUpload.HasFile = True Then
strGuid = fnGuid()
strPicExtension = fnGetPictureExtension(PhotoUpload.FileName)
strFileName = strGuid & strPicExtension
txtfoto.Text = strFileName
If strPicExtension <> "none" Then
subAddNewPicture(PhotoUpload, strFileName, "Imagenes")
Resize_Image(tamano_fotoP, tamano_fotoP, strFileName, "~/Imagenes/","P/")
Resize_Image(tamano_fotoG, tamano_fotoG, strFileName, "~/Imagenes/","G/")
sqldata.Insert()
PhotoUpload.PostedFile.InputStream.Dispose()
PhotoUpload.Dispose()
GC.Collect()
eliminar_foto(strFileName, "")
Else
lblmensaje.Text = "Por favor seleccione una imagen..."
End If
Else
lblmensaje.Text = "Por favor seleccione una imagen..."
End If
lblmensaje.Visible = True
Catch ex As Exception
End Try
End Sub
Protected Sub eliminar_temporales()
Dim file() As FileInfo
Dim i As Integer
Dim txtpath As String
txtpath = Path.Combine(Request.PhysicalApplicationPath, "Imagenes")
If txtpath <> "" Then
Dim dir As New DirectoryInfo(txtpath)
file = dir.GetFiles()
If file.Length > 0 Then
For i = 0 To file.Length - 1
Try
file(i).Delete()
Catch ex As Exception
'Throw ex
End Try
Next
End If
End If
End Sub
Public Sub eliminar_foto(ByVal nombre_foto As String, ByVal folder As String)
Dim strImagePath, strImageFolderPath As String
Try
strImageFolderPath = Path.Combine(Request.PhysicalApplicationPath, "Imagenes"& folder)
strImagePath = Path.Combine(strImageFolderPath, nombre_foto)
System.IO.File.Delete(strImagePath)
Catch ex As Exception
'Throw ex
End Try
End Sub
Public Sub Resize_Image(ByVal intMaxWidth As Short, ByVal intMaxHeigth As Short, ByValfoto As String, ByVal folder As String, ByVal atributo As String)
Dim img As Image
img = System.Drawing.Image.FromFile(MapPath(folder & foto))
Dim oImg As Bitmap = New System.Drawing.Bitmap(img)
'Assign image dimensions
Dim oldWidth As Integer
Dim oldHeight As Integer
Dim newWidth As Integer
Dim newHeight As Integer
Dim ratio As Decimal
oldWidth = oImg.Width
oldHeight = oImg.Height
ratio = oldWidth / oldHeight
newWidth = intMaxWidth
newHeight = newWidth / ratio
'rutina para ver si la foto es mas pequena del tamano a recortar dejandola igual
If oImg.Width < intMaxWidth Then
newWidth = oImg.Width
newHeight = oImg.Height
End If
Dim OutputBitmap As Bitmap = New Bitmap(oImg, CInt(newWidth), CInt(newHeight))
Dim encoderParams As System.Drawing.Imaging.EncoderParameters = NewSystem.Drawing.Imaging.EncoderParameters()
Dim quality As Long
Dim imageFormat = img.RawFormat
Dim myresizer As Graphics
myresizer = Graphics.FromImage(OutputBitmap)
'myresizer.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
'myresizer.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality
myresizer.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
myresizer.DrawImage(img, 0, 0, newWidth, newHeight)
'Compress image
Dim comp As Integer
If atributo = "G/" Then
comp = 60
Else
comp = 70
End If
quality = comp ' 0 to 100 - 100 highest quality
Dim encoderParam As System.Drawing.Imaging.EncoderParameter = NewSystem.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality)
encoderParams.Param(0) = encoderParam
Dim arrayICI As ImageCodecInfo() = ImageCodecInfo.GetImageEncoders()
Dim jpegICI As ImageCodecInfo
Dim x As Integer
For x = 0 To arrayICI.Length - 1
If (arrayICI(x).FormatDescription.Equals("JPEG")) Then
jpegICI = arrayICI(x)
Exit For
End If
Next
'Save original image
If Not jpegICI Is Nothing Then
OutputBitmap.Save(Server.MapPath(folder) & atributo & foto, jpegICI, encoderParams)
End If
' clean up
OutputBitmap.Dispose()
End Sub
#Region "Public Functions"
' Adds picture to specified folder
Public Sub subAddNewPicture(ByVal FileUploader As FileUpload, ByVal strPictureName AsString, ByVal strImgFolder As String)
Dim strImageFolderPath As String
Dim strImagePath As String
Try
' Construct saving path
strImageFolderPath = Path.Combine(Request.PhysicalApplicationPath, strImgFolder)
strImagePath = Path.Combine(strImageFolderPath, strPictureName)
' Upload image ACTUALIZADO
FileUploader.PostedFile.SaveAs(strImagePath)
FileUploader.PostedFile.InputStream.Dispose()
FileUploader.Dispose()
Catch ex As Exception
'Throw ex
End Try
End Sub
' Function to generate a GUID using current date and time
Public Function fnGuid() As String
Dim strGuid As String = ""
Try
With Today
strGuid = .Year & .Month & .Day & Now.Hour & Now.Minute & Now.Second
End With
Catch ex As Exception
Throw ex
End Try
' returning the guid generated
Return strGuid
End Function
' Returns true if file name has the extension .jpg, .gif, .jpeg
Public Function fnGetPictureExtension(ByVal strPictureName As String) As String
Try
With strPictureName.ToUpper
If .EndsWith(".JPG") Then
Return ".JPG"
ElseIf .EndsWith(".GIF") Then
Return ".GIF"
ElseIf .EndsWith(".JPEG") Then
Return ".JPEG"
ElseIf .EndsWith(".PNG") Then
Return ".PNG"
ElseIf .EndsWith(".BMP") Then
Return ".BMP"
End If
End With
Catch ex As Exception
Throw ex
End Try
' Else if has no extension so it returns ""
Return "none"
End Function
#End Region
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
telerik:RadStyleSheetManager
id
=
"RadStyleSheetManager1"
runat
=
"server"
/>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
<
Scripts
>
<%--Needed for JavaScript IntelliSense in VS2010--%>
<%--For VS2008 replace RadScriptManager with ScriptManager--%>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQueryInclude.js"
/>
</
Scripts
>
</
telerik:RadScriptManager
>
<
script
type
=
"text/javascript"
>
//Put your JavaScript code here.
</
script
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
</
telerik:RadAjaxManager
>
<
div
>
</
div
>
</
form
>
</
body
>
</
html
>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MyNewForm.aspx.cs" Inherits="MyRadControlsWebApp.MyNewForm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
</
div
>
</
form
>
</
body
>
</
html
>
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Prospects.ascx.cs" Inherits="Prospects" %>
<
telerik:RadCodeBlock
ID
=
"radcodeProspects"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function ShowEditForm(id, rowIndex) {
alert(id);
window.radopen("EditContact.aspx?ContactID=" + id, "UserListDialog");
return false;
}
function ShowInsertForm() {
window.radopen("EditContact.aspx", "UserListDialog");
return false;
}
function refreshGrid(arg) {
if (!arg) {
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
}
else {
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");
}
}
</
script
>
</
telerik:RadCodeBlock
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
OnAjaxRequest
=
"RadAjaxManager1_AjaxRequest"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadAjaxManager1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"prospectGrid"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"prospectGrid"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"prospectGrid"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadGrid
AllowSorting
=
"true"
BackColor
=
"#393939"
ID
=
"prospectGrid"
runat
=
"server"
AllowPaging
=
"true"
PageSize
=
"15"
Width
=
"980px"
CssClass
=
"productsGrid"
OnPreRender
=
"prospectGrid_PreRender"
OnItemCreated
=
"prospectGrid_ItemCreated"
OnNeedDataSource
=
"prospectGrid_NeedDataSource"
style
=
"outline:0"
>
<
MasterTableView
AutoGenerateColumns
=
"false"
PagerStyle-Mode
=
"NextPrevAndNumeric"
AllowFilteringByColumn
=
"false"
DataKeyNames
=
"OrderID"
ClientDataKeyNames
=
"OrderID"
TableLayout
=
"Fixed"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"OrderID"
HeaderText
=
"ProspectID"
AutoPostBackOnFilter
=
"true"
ShowFilterIcon
=
"false"
HeaderStyle-Width
=
"70px"
FilterControlWidth
=
"35px"
>
</
telerik:GridBoundColumn
>
<
telerik:GridNumericColumn
DataField
=
"Freight"
HeaderText
=
"Freight"
DataFormatString
=
"{0:c}"
HeaderStyle-Width
=
"110px"
FilterControlWidth
=
"60px"
>
</
telerik:GridNumericColumn
>
<
telerik:GridBoundColumn
DataField
=
"ShipName"
HeaderText
=
"Prospect Name"
HeaderStyle-Width
=
"300px"
FilterControlWidth
=
"260px"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ShipCountry"
HeaderText
=
"Country"
FilterControlWidth
=
"70px"
>
</
telerik:GridBoundColumn
>
<
telerik:GridDateTimeColumn
DataField
=
"OrderDate"
HeaderText
=
"Order Date"
DataFormatString
=
"{0:d}"
FilterControlWidth
=
"95px"
>
</
telerik:GridDateTimeColumn
>
<
telerik:GridDateTimeColumn
DataField
=
"ShippedDate"
HeaderText
=
"Shipping Date"
DataFormatString
=
"{0:d}"
FilterControlWidth
=
"95px"
>
</
telerik:GridDateTimeColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"TemplateEditColumn"
>
<
ItemTemplate
>
<
asp:HyperLink
ID
=
"EditLink"
runat
=
"server"
Text
=
"Edit"
></
asp:HyperLink
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
AllowDragToGroup
=
"false"
EnableRowHoverStyle
=
"true"
>
<
Selecting
AllowRowSelect
=
"true"
/>
<
Scrolling
AllowScroll
=
"true"
UseStaticHeaders
=
"true"
ScrollHeight
=
"360px"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
<
telerik:RadWindowManager
ID
=
"RadWindowManager1"
runat
=
"server"
EnableShadow
=
"true"
>
<
Windows
>
<
telerik:RadWindow
ID
=
"UserListDialog"
runat
=
"server"
Title
=
"Editing record"
Height
=
"320px"
Width
=
"310px"
Left
=
"150px"
ReloadOnShow
=
"true"
ShowContentDuringLoad
=
"false"
Modal
=
"true"
/>
</
Windows
>
</
telerik:RadWindowManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"ProductsLoadingPanel"
runat
=
"server"
></
telerik:RadAjaxLoadingPanel
>
protected
void
prospectGrid_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
HyperLink editLink = (HyperLink)e.Item.FindControl(
"EditLink"
);
editLink.Attributes[
"href"
] =
"#"
;
editLink.Attributes[
"onclick"
] = String.Format(
"return ShowEditForm('{0}','{1}');"
, e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][
"OrderID"
], e.Item.ItemIndex);
}
}
protected
void
RadAjaxManager1_AjaxRequest(
object
sender, AjaxRequestEventArgs e)
{
if
(e.Argument ==
"Rebind"
)
{
prospectGrid.MasterTableView.SortExpressions.Clear();
prospectGrid.MasterTableView.GroupByExpressions.Clear();
prospectGrid.Rebind();
}
else
if
(e.Argument ==
"RebindAndNavigate"
)
{
prospectGrid.MasterTableView.SortExpressions.Clear();
prospectGrid.MasterTableView.GroupByExpressions.Clear();
prospectGrid.MasterTableView.CurrentPageIndex = prospectGrid.MasterTableView.PageCount - 1;
prospectGrid.Rebind();
}
}
<telerik:RadScriptManager runat=
"server"
ID=
"RadScriptManager1"
>
<Scripts>
<asp:ScriptReference Assembly=
"Telerik.Web.UI"
Name=
"Telerik.Web.UI.Common.Core.js"
/>
<asp:ScriptReference Assembly=
"Telerik.Web.UI"
Name=
"Telerik.Web.UI.Common.jQuery.js"
/>
<asp:ScriptReference Path=
"~/Scripts/jquery.maphilight.min.js"
/>
<asp:ScriptReference Path=
"~/Scripts/maphilight.js"
/>
</Scripts>
</telerik:RadScriptManager>
function
HighlightNode(value) {
var
tree = $find(
"<%= RadTreeView1.ClientID %>"
);
var
node = tree.findNodeByValue(value);
if
(node !=
null
) {
node.startEdit();
}
}
Dim
script
As
String
=
"HighlightNode("
""
+ newNode.Value +
""
")"
RadAjaxManager1.ResponseScripts.Add(script)