2010-04-05 7 views
0

alt text http://[url=http://www.freeimagehosting.net/][img]http://www.freeimagehosting.net/uploads/06e679a07d.jpg[/img][/url]comment changer un bouton dans une ImageButton en asp.net C#

Comment changer le bouton en bouton d'image ... le bouton au début a « Choisissez une date » lorsque vous cliquez dessus un calendrier ressorte et Quand une date est sélectionnée, une étiquette en bas de la page indique que la date est entrée et que le texte sur le bouton est désactivé ... Je veux placer un bouton image ayant une icône d'image du calendrier et le reste de la fonction sera le même ....

le code comme suit:

using System; en utilisant System.Collections.Generic; en utilisant System.ComponentModel; en utilisant System.Text; en utilisant System.Web; en utilisant System.Web.UI; en utilisant System.Web.UI.WebControls;

[assemblage: TagPrefix ("DatePicker", "EWS")] espace de noms EclipseWebSolutions.DatePicker { [DefaultProperty ("Texte")] [ToolboxData ("< {0}: DatePicker runat = server>")] [DefaultEvent ("selectionChanged")] [ValidationProperty ("TextValue")] public class DatePicker: WebControl, INamingContainer { #region Propriétés

public TextBox txtDate = new TextBox(); 
    public Calendar calDate = new Calendar(); 
    public Button btnDate = new Button(); 
    public Panel pnlCalendar = new Panel(); 

    private enum ViewStateConstants 
    { 
     ValidationGroup, 
     RegularExpression, 
     ErrorMessage, 
     RegExText, 
     CalendarPosition, 
     FormatString, 
     ExpandLabel, 
     CollapseLabel, 
     ApplyDefaultStyle, 
     CausesValidation, 
    } 

    /// <summary> 
    /// Defines the available display modes of this calendar. 
    /// </summary> 
    public enum CalendarDisplay 
    { 
     DisplayRight, 
     DisplayBelow 
    } 

    /// <summary> 
    /// Where to display the popup calendar. 
    /// </summary> 
    [Category("Behaviour")] 
    [Localizable(true)] 
    public CalendarDisplay CalendarPosition 
    { 
     get 
     { 
      if (ViewState[ViewStateConstants.CalendarPosition.ToString()] == null) 
      { 
       ViewState[ViewStateConstants.CalendarPosition.ToString()] = CalendarDisplay.DisplayRight; 
      } 
      return (CalendarDisplay)ViewState[ViewStateConstants.CalendarPosition.ToString()]; 
     } 
     set 
     { 
      ViewState[ViewStateConstants.CalendarPosition.ToString()] = value; 
     } 
    } 

    /// <summary> 
    /// Text version of the control's value, for use by ASP.NET validators. 
    /// </summary> 
    public string TextValue 
    { 
     get { return txtDate.Text; } 
    } 

    /// <summary> 
    /// Holds the current date value of this control. 
    /// </summary> 
    [Category("Behaviour")] 
    [Localizable(true)] 
    [Bindable(true, BindingDirection.TwoWay)] 
    public DateTime DateValue 
    { 
     get 
     { 
      try 
      { 
       if (txtDate.Text == "") return DateTime.MinValue; 

       DateTime val = DateTime.Parse(txtDate.Text); 
       return val; 
      } 
      catch (ArgumentNullException) 
      { 
       return DateTime.MinValue; 
      } 
      catch (FormatException) 
      { 
       return DateTime.MinValue; 
      } 
     } 
     set 
     { 
      if (value == DateTime.MinValue) 
      { 
       txtDate.Text = ""; 
      } 
      else 
      { 
       txtDate.Text = value.ToShortDateString(); 
      } 
     } 
    } 

    [Category("Behavior"), Themeable(false), DefaultValue("")] 
    public virtual string ValidationGroup 
    { 
     get 
     { 
      if (ViewState[ViewStateConstants.ValidationGroup.ToString()] == null) 
      { 
       return string.Empty; 
      } 
      else 
      { 
       return (string)ViewState[ViewStateConstants.ValidationGroup.ToString()]; 
      } 
     } 
     set 
     { 
      ViewState[ViewStateConstants.ValidationGroup.ToString()] = value; 
     } 
    } 

    /// <summary> 
    /// The label of the exand button. Shown when the calendar is hidden. 
    /// </summary> 
    [Bindable(true)] 
    [Category("Appearance")] 
    [DefaultValue("PickDate")] 
    [Localizable(true)] 
    public string ExpandButtonLabel 
    { 
     get 
     { 
      String s = (String)ViewState[ViewStateConstants.ExpandLabel.ToString()]; 
      return ((s == null) ? "PickDate" : s); 
     } 
     set 
     { 
      ViewState[ViewStateConstants.ExpandLabel.ToString()] = value; 
     } 
    } 

    /// <summary> 
    /// The label of the collapse button. Shown when the calendar is visible. 
    /// </summary> 
    [Bindable(true)] 
    [Category("Appearance")] 
    [DefaultValue("Disabled")] 
    [Localizable(true)] 
    public string CollapseButtonLabel 
    { 
     get 
     { 
      String s = (String)ViewState[ViewStateConstants.CollapseLabel.ToString()]; 
      return ((s == null) ? "Disabled" : s); 
     } 
     set 
     { 
      ViewState[ViewStateConstants.CollapseLabel.ToString()] = value; 
     } 
    } 

    /// <summary> 
    /// Whether to apply the default style. Disable this if you want to apply a custom style, or to use themes and skins 
    /// to style the control. 
    /// </summary> 
    [Category("Appearance")] 
    [DefaultValue(true)] 
    [Localizable(true)] 
    public bool ApplyDefaultStyle 
    { 
     get 
     { 
      if (ViewState[ViewStateConstants.ApplyDefaultStyle.ToString()] == null) 
      { 
       ViewState[ViewStateConstants.ApplyDefaultStyle.ToString()] = true; 
      } 
      return (bool)ViewState[ViewStateConstants.ApplyDefaultStyle.ToString()]; 
     } 
     set 
     { 
      ViewState[ViewStateConstants.ApplyDefaultStyle.ToString()] = value; 
     } 
    } 

    /// <summary>   
    /// Causes Validation   
    /// </summary>   
    [Category("Appearance")] 
    [DefaultValue(false)] 
    [Localizable(false)] 
    public bool CausesValidation 
    { 
     get 
     { 
      if (ViewState[ViewStateConstants.CausesValidation.ToString()] == null) 
      { 
       ViewState[ViewStateConstants.CausesValidation.ToString()] = false; 
      } 
      return (bool)ViewState[ViewStateConstants.CausesValidation.ToString()]; 
     } 
     set 
     { 
      ViewState[ViewStateConstants.CausesValidation.ToString()] = value; 
      btnDate.CausesValidation = value; 
     } 
    } 

    #endregion 

    #region Events 

    /// <summary> 
    /// A day was selected from the calendar control. 
    /// </summary> 
    public event EventHandler SelectionChanged; 

    protected virtual void OnSelectionChanged() 
    { 
     if (SelectionChanged != null) // only raise the event if someone is listening. 
     { 
      SelectionChanged(this, EventArgs.Empty); 
     } 
    } 

    #endregion 

    #region Event Handlers 

    /// <summary> 
    /// The +/- button was clicked. 
    /// </summary> 
    protected void btnDate_Click(object sender, System.EventArgs e) 
    { 
     if (!calDate.Visible) 
     { 
      // expand the calendar 
      calDate.Visible = true; 
      txtDate.Enabled = false; 
      btnDate.Text = CollapseButtonLabel; 
      if (DateValue != DateTime.MinValue) 
      { 
       calDate.SelectedDate = DateValue; 
       calDate.VisibleDate = DateValue; 
      } 
     } 
     else 
     { 
      // collapse the calendar 
      calDate.Visible = false; 
      txtDate.Enabled = true; 
      btnDate.Text = ExpandButtonLabel; 
     } 
    } 

    /// <summary> 
    /// A date was selected from the calendar. 
    /// </summary> 
    protected void calDate_SelectionChanged(object sender, System.EventArgs e) 
    { 
     calDate.Visible = false; 
     txtDate.Visible = true; 
     btnDate.Text = ExpandButtonLabel; 
     txtDate.Enabled = true; 
     txtDate.Text = calDate.SelectedDate.ToShortDateString(); 
     OnSelectionChanged(); 
    } 

    #endregion 

    /// <summary> 
    /// Builds the contents of this control. 
    /// </summary> 
    protected override void CreateChildControls() 
    { 
     btnDate.Text = ExpandButtonLabel; 
     btnDate.CausesValidation = CausesValidation; 
     txtDate.ID = "txtDate"; 

     calDate.Visible = false; 

     if (ApplyDefaultStyle) 
     { 
      calDate.BackColor = System.Drawing.Color.White; 
      calDate.BorderColor = System.Drawing.Color.FromArgb(10066329); 
      calDate.CellPadding = 2; 
      calDate.DayNameFormat = DayNameFormat.Shortest; 
      calDate.Font.Name = "Verdana"; 
      calDate.Font.Size = FontUnit.Parse("8pt"); 
      calDate.ForeColor = System.Drawing.Color.Black; 
      calDate.Height = new Unit(150, UnitType.Pixel); 
      calDate.Width = new Unit(180, UnitType.Pixel); 
      calDate.DayHeaderStyle.BackColor = System.Drawing.Color.FromArgb(228, 228, 228); 
      calDate.DayHeaderStyle.Font.Size = FontUnit.Parse("7pt"); 
      calDate.TitleStyle.Font.Bold = true; 
      calDate.WeekendDayStyle.BackColor = System.Drawing.Color.FromArgb(255, 255, 204); 
     } 

     ConnectEventHandlers(); 

     pnlCalendar.Controls.Add(calDate); 
     pnlCalendar.Style["position"] = "absolute"; 
     pnlCalendar.Style["filter"] = "alpha(opacity=95)"; 
     pnlCalendar.Style["-moz-opacity"] = ".95"; 
     pnlCalendar.Style["opacity"] = ".95"; 
     pnlCalendar.Style["z-index"] = "2"; 
     pnlCalendar.Style["background-color"] = "White"; 

     if (CalendarPosition == CalendarDisplay.DisplayBelow) 
     { 
      pnlCalendar.Style["margin-top"] = "27px"; 
     } 
     else 
     { 
      pnlCalendar.Style["display"] = "inline"; 
     } 

     Controls.Add(txtDate); 
     Controls.Add(pnlCalendar); 
     Controls.Add(btnDate); 

     base.CreateChildControls(); 
    } 

    /// <summary> 
    /// Render the contents of this control. 
    /// </summary> 
    /// <param name="output">The HtmlTextWriter to use.</param> 
    protected override void RenderContents(HtmlTextWriter output) 
    { 
     switch (CalendarPosition) 
     { 
      case CalendarDisplay.DisplayRight: 
       { 
        txtDate.RenderControl(output); 
        btnDate.RenderControl(output); 
        pnlCalendar.RenderControl(output); 
        break; 
       } 
      case CalendarDisplay.DisplayBelow: 
       { 
        pnlCalendar.RenderControl(output); 
        txtDate.RenderControl(output); 
        btnDate.RenderControl(output); 
        break; 
       } 
     } 
    } 

    /// <summary> 
    /// Connect event handlers to events. 
    /// </summary> 
    private void ConnectEventHandlers() 
    { 
     btnDate.Click += new System.EventHandler(btnDate_Click); 
     calDate.SelectionChanged += new System.EventHandler(calDate_SelectionChanged); 
    } 

} 

}

en utilisant System; en utilisant System.Collections.Generic; en utilisant System.ComponentModel; en utilisant System.Text; en utilisant System.Web; en utilisant System.Web.UI; en utilisant System.Web.UI.WebControls; [Assembly: TagPrefix ("DatePicker", "EWS")] namespace EclipseWebSolutions.DatePicker { [DefaultProperty ("Texte")] [ToolboxData ("< {0}: DatePicker runat = server> ")] [DefaultEvent (" SelectionChanged ")] [ValidationProperty (" TextValue")] publique classe DatePicker: WebControl, INamingContainer { #region Propriétés

public TextBox txtDate = new TextBox(); 
    public Calendar calDate = new Calendar(); 
    public Button btnDate = new Button(); 
    public Panel pnlCalendar = new Panel(); 

    private enum ViewStateConstants 
    { 
     ValidationGroup, 
     RegularExpression, 
     ErrorMessage, 
     RegExText, 
     CalendarPosition, 
     FormatString, 
     ExpandLabel, 
     CollapseLabel, 
     ApplyDefaultStyle, 
     CausesValidation, 
    } 

    /// <summary> 
    /// Defines the available display modes of this calendar. 
    /// </summary> 
    public enum CalendarDisplay 
    { 
     DisplayRight, 
     DisplayBelow 
    } 

    /// <summary> 
    /// Where to display the popup calendar. 
    /// </summary> 
    [Category("Behaviour")] 
    [Localizable(true)] 
    public CalendarDisplay CalendarPosition 
    { 
     get 
     { 
      if (ViewState[ViewStateConstants.CalendarPosition.ToString()] == null) 
      { 
       ViewState[ViewStateConstants.CalendarPosition.ToString()] = CalendarDisplay.DisplayRight; 
      } 
      return (CalendarDisplay)ViewState[ViewStateConstants.CalendarPosition.ToString()]; 
     } 
     set 
     { 
      ViewState[ViewStateConstants.CalendarPosition.ToString()] = value; 
     } 
    } 

    /// <summary> 
    /// Text version of the control's value, for use by ASP.NET validators. 
    /// </summary> 
    public string TextValue 
    { 
     get { return txtDate.Text; } 
    } 

    /// <summary> 
    /// Holds the current date value of this control. 
    /// </summary> 
    [Category("Behaviour")] 
    [Localizable(true)] 
    [Bindable(true, BindingDirection.TwoWay)] 
    public DateTime DateValue 
    { 
     get 
     { 
      try 
      { 
       if (txtDate.Text == "") return DateTime.MinValue; 

       DateTime val = DateTime.Parse(txtDate.Text); 
       return val; 
      } 
      catch (ArgumentNullException) 
      { 
       return DateTime.MinValue; 
      } 
      catch (FormatException) 
      { 
       return DateTime.MinValue; 
      } 
     } 
     set 
     { 
      if (value == DateTime.MinValue) 
      { 
       txtDate.Text = ""; 
      } 
      else 
      { 
       txtDate.Text = value.ToShortDateString(); 
      } 
     } 
    } 

    [Category("Behavior"), Themeable(false), DefaultValue("")] 
    public virtual string ValidationGroup 
    { 
     get 
     { 
      if (ViewState[ViewStateConstants.ValidationGroup.ToString()] == null) 
      { 
       return string.Empty; 
      } 
      else 
      { 
       return (string)ViewState[ViewStateConstants.ValidationGroup.ToString()]; 
      } 
     } 
     set 
     { 
      ViewState[ViewStateConstants.ValidationGroup.ToString()] = value; 
     } 
    } 

    /// <summary> 
    /// The label of the exand button. Shown when the calendar is hidden. 
    /// </summary> 
    [Bindable(true)] 
    [Category("Appearance")] 
    [DefaultValue("PickDate")] 
    [Localizable(true)] 
    public string ExpandButtonLabel 
    { 
     get 
     { 
      String s = (String)ViewState[ViewStateConstants.ExpandLabel.ToString()]; 
      return ((s == null) ? "PickDate" : s); 
     } 
     set 
     { 
      ViewState[ViewStateConstants.ExpandLabel.ToString()] = value; 
     } 
    } 

    /// <summary> 
    /// The label of the collapse button. Shown when the calendar is visible. 
    /// </summary> 
    [Bindable(true)] 
    [Category("Appearance")] 
    [DefaultValue("Disabled")] 
    [Localizable(true)] 
    public string CollapseButtonLabel 
    { 
     get 
     { 
      String s = (String)ViewState[ViewStateConstants.CollapseLabel.ToString()]; 
      return ((s == null) ? "Disabled" : s); 
     } 
     set 
     { 
      ViewState[ViewStateConstants.CollapseLabel.ToString()] = value; 
     } 
    } 

    /// <summary> 
    /// Whether to apply the default style. Disable this if you want to apply a custom style, or to use themes and skins 
    /// to style the control. 
    /// </summary> 
    [Category("Appearance")] 
    [DefaultValue(true)] 
    [Localizable(true)] 
    public bool ApplyDefaultStyle 
    { 
     get 
     { 
      if (ViewState[ViewStateConstants.ApplyDefaultStyle.ToString()] == null) 
      { 
       ViewState[ViewStateConstants.ApplyDefaultStyle.ToString()] = true; 
      } 
      return (bool)ViewState[ViewStateConstants.ApplyDefaultStyle.ToString()]; 
     } 
     set 
     { 
      ViewState[ViewStateConstants.ApplyDefaultStyle.ToString()] = value; 
     } 
    } 

    /// <summary>   
    /// Causes Validation   
    /// </summary>   
    [Category("Appearance")] 
    [DefaultValue(false)] 
    [Localizable(false)] 
    public bool CausesValidation 
    { 
     get 
     { 
      if (ViewState[ViewStateConstants.CausesValidation.ToString()] == null) 
      { 
       ViewState[ViewStateConstants.CausesValidation.ToString()] = false; 
      } 
      return (bool)ViewState[ViewStateConstants.CausesValidation.ToString()]; 
     } 
     set 
     { 
      ViewState[ViewStateConstants.CausesValidation.ToString()] = value; 
      btnDate.CausesValidation = value; 
     } 
    } 

    #endregion 

    #region Events 

    /// <summary> 
    /// A day was selected from the calendar control. 
    /// </summary> 
    public event EventHandler SelectionChanged; 

    protected virtual void OnSelectionChanged() 
    { 
     if (SelectionChanged != null) // only raise the event if someone is listening. 
     { 
      SelectionChanged(this, EventArgs.Empty); 
     } 
    } 

    #endregion 

    #region Event Handlers 

    /// <summary> 
    /// The +/- button was clicked. 
    /// </summary> 
    protected void btnDate_Click(object sender, System.EventArgs e) 
    { 
     if (!calDate.Visible) 
     { 
      // expand the calendar 
      calDate.Visible = true; 
      txtDate.Enabled = false; 
      btnDate.Text = CollapseButtonLabel; 
      if (DateValue != DateTime.MinValue) 
      { 
       calDate.SelectedDate = DateValue; 
       calDate.VisibleDate = DateValue; 
      } 
     } 
     else 
     { 
      // collapse the calendar 
      calDate.Visible = false; 
      txtDate.Enabled = true; 
      btnDate.Text = ExpandButtonLabel; 
     } 
    } 

    /// <summary> 
    /// A date was selected from the calendar. 
    /// </summary> 
    protected void calDate_SelectionChanged(object sender, System.EventArgs e) 
    { 
     calDate.Visible = false; 
     txtDate.Visible = true; 
     btnDate.Text = ExpandButtonLabel; 
     txtDate.Enabled = true; 
     txtDate.Text = calDate.SelectedDate.ToShortDateString(); 
     OnSelectionChanged(); 
    } 

    #endregion 

    /// <summary> 
    /// Builds the contents of this control. 
    /// </summary> 
    protected override void CreateChildControls() 
    { 
     btnDate.Text = ExpandButtonLabel; 
     btnDate.CausesValidation = CausesValidation; 
     txtDate.ID = "txtDate"; 

     calDate.Visible = false; 

     if (ApplyDefaultStyle) 
     { 
      calDate.BackColor = System.Drawing.Color.White; 
      calDate.BorderColor = System.Drawing.Color.FromArgb(10066329); 
      calDate.CellPadding = 2; 
      calDate.DayNameFormat = DayNameFormat.Shortest; 
      calDate.Font.Name = "Verdana"; 
      calDate.Font.Size = FontUnit.Parse("8pt"); 
      calDate.ForeColor = System.Drawing.Color.Black; 
      calDate.Height = new Unit(150, UnitType.Pixel); 
      calDate.Width = new Unit(180, UnitType.Pixel); 
      calDate.DayHeaderStyle.BackColor = System.Drawing.Color.FromArgb(228, 228, 228); 
      calDate.DayHeaderStyle.Font.Size = FontUnit.Parse("7pt"); 
      calDate.TitleStyle.Font.Bold = true; 
      calDate.WeekendDayStyle.BackColor = System.Drawing.Color.FromArgb(255, 255, 204); 
     } 

     ConnectEventHandlers(); 

     pnlCalendar.Controls.Add(calDate); 
     pnlCalendar.Style["position"] = "absolute"; 
     pnlCalendar.Style["filter"] = "alpha(opacity=95)"; 
     pnlCalendar.Style["-moz-opacity"] = ".95"; 
     pnlCalendar.Style["opacity"] = ".95"; 
     pnlCalendar.Style["z-index"] = "2"; 
     pnlCalendar.Style["background-color"] = "White"; 

     if (CalendarPosition == CalendarDisplay.DisplayBelow) 
     { 
      pnlCalendar.Style["margin-top"] = "27px"; 
     } 
     else 
     { 
      pnlCalendar.Style["display"] = "inline"; 
     } 

     Controls.Add(txtDate); 
     Controls.Add(pnlCalendar); 
     Controls.Add(btnDate); 

     base.CreateChildControls(); 
    } 

    /// <summary> 
    /// Render the contents of this control. 
    /// </summary> 
    /// <param name="output">The HtmlTextWriter to use.</param> 
    protected override void RenderContents(HtmlTextWriter output) 
    { 
     switch (CalendarPosition) 
     { 
      case CalendarDisplay.DisplayRight: 
       { 
        txtDate.RenderControl(output); 
        btnDate.RenderControl(output); 
        pnlCalendar.RenderControl(output); 
        break; 
       } 
      case CalendarDisplay.DisplayBelow: 
       { 
        pnlCalendar.RenderControl(output); 
        txtDate.RenderControl(output); 
        btnDate.RenderControl(output); 
        break; 
       } 
     } 
    } 

    /// <summary> 
    /// Connect event handlers to events. 
    /// </summary> 
    private void ConnectEventHandlers() 
    { 
     btnDate.Click += new System.EventHandler(btnDate_Click); 
     calDate.SelectionChanged += new System.EventHandler(calDate_SelectionChanged); 
    } 

} 

}

Untitled Page
 


 
 

en utilisant System; en utilisant System.Data; en utilisant System.Configuration; en utilisant System.Web; en utilisant System.Web.Security; en utilisant System.Web.UI; en utilisant System.Web.UI.WebControls; en utilisant System.Web.UI.WebControls.WebParts; en utilisant System.Web.UI.HtmlControls;

public partial class _Default: System.Web.UI.Page { protected void Page_Load (expéditeur d'objet, EventArgs e) {

} 

protected void DatePicker1_SelectionChanged(object sender, EventArgs e) 
{ 
    Label1.Text = DatePicker1.DateValue.ToShortDateString(); 
    pnlLabel.Update(); 
} 

}

+0

Pouvez-vous éditer votre question, et ne republiez que le code correspondant !! –

Répondre

1

pour faire le bouton une image pourrait simplement le style pour ajouter une image de fond.

btnDate.style["background-image"] ="url(images/btn.jpg)"; 
btnDate.text=""; 
+0

si mon URL pour l'image est "C: \ Projets \ iis \ DatePickerDemo \ images.jpg" comment vais-je le mettre dans le: btnDate.style ["background-image"] = "C: \ Projects \ iis \ DatePickerDemo \ images.jpg "; – sweetsecret

+0

quelle est "l'image de fond" que vous avez utilisée; – sweetsecret

+0

l'URL que vous utilisez serait la position relative sur le serveur web si DatePickerDemo est votre répertoire racine vous utiliseriez url (/images.jpg) – Glennular

0

Html, un bouton d'image a un attribut type de 'image' et un attribut src utilisé pour déterminer l'image à afficher. Donc, pour changer un bouton standard à un bouton image vous devez:

buttonControl.Attributes["type"] = "image"; 
buttonControl.Attributes["src"] = "Foo.jpg"; 

EDIT Si vous essayez de changer le type de bouton en cas de clic, vous pourriez être tenu de le faire via javascript client -côté. Vous pouvez le faire en vous inscrivant un script de démarrage dans l'événement Click comme ceci:

protected void Button_OnClick(object sender, EventArgs e) 
{ 
    var button = sender as Button; 
    if (button == null) 
     return; 

    var jsScript = new StringBuilder(); 
    jsScript.AppendFormat("<script type=\"text/javascript\">"); 
    jsScript.AppendFormat("var button = document.getElementById(\"{0}\"); button.type = \"image\"; button.src=\"Foo.jpg\";" 
      , button.ClientID); 
    jsScript.Append("</script>"); 

    if (!Page.ClientScript.IsStartupScriptRegistered(typeof(Page), "resetImageButton")) 
     Page.ClientScript.RegisterStartupScript(typeof(Page), "resetImageButton", jsScript.ToString(), false); 
} 

Le hic est que cela ne fonctionnera juste après le postback déclenché en cliquant sur le bouton. Il ne survivra pas à plusieurs publications.Pour cela, vous devez stocker un drapeau dans un champ de texte caché ou ViewState qui indique quel type le bouton doit être et ensuite, en fonction de cela, déterminez si vous avez besoin d'enregistrer ce script de démarrage ou non.

+0

cela n'affecte pas je ne peux pas c l'image que je veux ajouter dans le bouton wen je l'exécute. – sweetsecret

+0

Quel événement devrait déclencher le changement du bouton d'un bouton normal à un ImageButton? Est-ce dans la méthode CreateChildControls? L'événement Click du bouton? – Thomas

+0

la méthode CreateChildcontrols ... Je veux juste utiliser un bouton avec l'image au lieu du bouton avec le texte "choisir une date" reste les fonctions seront les mêmes – sweetsecret

Questions connexes