martedì 29 gennaio 2013
Castare un DateTime in formato Date
(SELECT CONVERT(VARCHAR(10), pn_datreg, 103) AS [DD/MM/YYYY]) as datreg
lunedì 28 gennaio 2013
UpdateProgress
E' possibile utilizzare un UpdateProgress abbinato all' UpdatePanel per fare in modo di visualizzare un'immagine di "attesa" durante il caricamento del pannello.
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<div style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
<asp:Image ID="imgUpdateProgress" runat="server" ImageUrl="images/ajax-Progress.gif" AlternateText="Attendere prego..." ToolTip="Attendere prego..." style="padding: 10px;position:fixed;top:45%;left:50%;" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
</ContentTemplate>
</asp:UpdatePanel>
E' possibile personalizzare l'immagine visualizzata creandola da questo portale:
http://www.ajaxload.info/
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<div style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
<asp:Image ID="imgUpdateProgress" runat="server" ImageUrl="images/ajax-Progress.gif" AlternateText="Attendere prego..." ToolTip="Attendere prego..." style="padding: 10px;position:fixed;top:45%;left:50%;" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
</ContentTemplate>
</asp:UpdatePanel>
E' possibile personalizzare l'immagine visualizzata creandola da questo portale:
http://www.ajaxload.info/
giovedì 24 gennaio 2013
Scatenare l'evento postback all'interno di un UpdatePanel
Per far in modo che un elemento all'interno di un UpdatePanel scateni un postback, aggiungere queste righe nel Page_Load
Dim scriptManager As ScriptManager = scriptManager.GetCurrent(Me.Page)
scriptManager.RegisterPostBackControl(btnFattura)
Se invece abbiamo la necessità di far scatenare un evneto JavaScript dal CodeBehind è necesserio utilizzare questa procedura:
Dim ObjScript As String = "openWinINFO('" & Nota & "');"
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), Guid.NewGuid().ToString(), ObjScript, True)
Dim scriptManager As ScriptManager = scriptManager.GetCurrent(Me.Page)
scriptManager.RegisterPostBackControl(btnFattura)
Se invece abbiamo la necessità di far scatenare un evneto JavaScript dal CodeBehind è necesserio utilizzare questa procedura:
Dim ObjScript As String = "openWinINFO('" & Nota & "');"
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), Guid.NewGuid().ToString(), ObjScript, True)
lunedì 21 gennaio 2013
TRY CATCH in Sql Server
Con questa procedura è possibile intercettare un particolare errore (in questo caso un Deadlock), e rieseguire la procedura richiesta, per un determinato numero di volte (per evitare un loop)
DECLARE @RetryCounter INT
SET @RetryCounter = 1
RETRY: -- Label RETRY
BEGIN TRANSACTION
BEGIN TRY
UPDATE Customer SET LastName = 'John' WHERE CustomerId=111
COMMIT TRANSACTION
END TRY
BEGIN CATCH
PRINT 'Rollback Transaction'
ROLLBACK TRANSACTION
DECLARE @DoRetry bit; -- Whether to Retry transaction or not
DECLARE @ErrorMessage varchar(500)
SET @doRetry = 0;
SET @ErrorMessage = ERROR_MESSAGE()
IF ERROR_NUMBER() = 1205 -- Deadlock Error Number
BEGIN
SET @doRetry = 1; -- Set @doRetry to 1 only for Deadlock
END
IF @DoRetry = 1
BEGIN
SET @RetryCounter = @RetryCounter + 1 -- Increment Retry Counter By one
IF (@RetryCounter > 3) -- Check whether Retry Counter reached to 3
BEGIN
RAISERROR(@ErrorMessage, 18, 1) -- Raise Error Message if
-- still deadlock occurred after three retries
END
ELSE
BEGIN
WAITFOR DELAY '00:00:00.05' -- Wait for 5 ms
GOTO RETRY -- Go to Label RETRY
END
END
ELSE
BEGIN
RAISERROR(@ErrorMessage, 18, 1)
END
END CATCH
mercoledì 2 gennaio 2013
leggere un valore dalla radgrid on ItemCommand
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
Dim action As String = e.CommandName
If (action = "XXX") Then
Dim id As Integer = e.CommandArgument
Dim item As GridItem = DirectCast(e.Item, GridItem)
' definire l'oggetto da leggere
Dim campo As HiddenField = DirectCast(DirectCast(item, Telerik.Web.UI.GridDataItem).FindControl("hiddenCampo"), HiddenField)
'definire il tipo di dato i uscita
Dim valore As String = campo.Value
End If
End Sub
Iscriviti a:
Post (Atom)