ciao!
io questo pezzo di codice nel Page_load:
sarebbe possibile identificare qualce componente ha inviato il post back??codice:Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If IsPostBack Then inviaRic() End If End Sub
ciao!
io questo pezzo di codice nel Page_load:
sarebbe possibile identificare qualce componente ha inviato il post back??codice:Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If IsPostBack Then inviaRic() End If End Sub
trovato questo
l'else è abbastanza "discutibile"...codice:public static Control GetPostBackControl(Page page) { Control control = null; string ctrlname = page.Request.Params.Get("__EVENTTARGET"); if (ctrlname != null && ctrlname != string.Empty) { control = page.FindControl(ctrlname); } else { foreach (string ctl in page.Request.Form) { Control c = page.FindControl(ctl); if (c is System.Web.UI.WebControls.Button) { control = c; break; } } } return control; }
W la Ferari effetrenavenave!
il computer è un somaro veloce! (neanche tanto ndr)
ma non è sender, l'oggetto in questione ?
(la butto sul facile, ma ricordo che anche io poi ci ho sbattuto non poco)
press play on tape
-----
MP3 Listing
https://sourceforge.net/projects/mp3-listing
File Listing
https://sourceforge.net/projects/file-listing-2-0/
Questo è codice fatto tanto tempo fa
Comunque non l'ho mai usato perchè mi trovo meglio con la gestione degli eventi fatta da .net
codice:Option Strict On Partial Class Chi_ha_effettuato_il_postback_postback Inherits System.Web.UI.Page Private ChiHaFattoPostBackID As String = "" Private Sub Page_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Me.Label1.Text = "" If Me.IsPostBack Then If ChiHaFattoPostBackID = "" Then If (Trim(Me.Request.Form("__EVENTTARGET")) <> "") Then ChiHaFattoPostBackID = Trim(Me.Request.Form("__EVENTTARGET")) & " (__EVENTTARGET)" End If End If 'Label1.Text contiene l'id di chi ha fatto il postback Me.Label1.Text = ChiHaFattoPostBackID Else End If End Sub Public Overrides Sub RegisterRequiresRaiseEvent(control As System.Web.UI.IPostBackEventHandler) MyBase.RegisterRequiresRaiseEvent(control) Me.ChiHaFattoPostBackID = (DirectCast(control, WebControl).UniqueID) & " (RegisterRequiresRaiseEvent)" End Sub End Class
Pietro
ciao!
scusate il ritardo.
allora:
se clicco uno dei due tasti, tutto ok.codice:If IsPostBack Then Dim ctrlname As String = Me.Request.Form("__EVENTTARGET") Dim ctrl As Control = Me.FindControl(ctrlname) If ctrl IsNot Nothing AndAlso ctrl.ClientID = "btnUpRichiesta" Or ctrl.ClientID = "btnInviaRichiesta" Then Diagnostics.Debug.WriteLine(ctrl.ClientID) End If 'inviaRic() End If
se nella input text do invio dicendomi che ctrl era Nothing.
però in teoria non l'ho eseguito il controllo?
o ho sbagliato nella if??