locked
How to add attributes in a MobileControl? RRS feed

  • Question

  • User-375488743 posted

    In WebForms I use in code behind:

    someWebControl.Attributes.Add(key, value)

    What should I do to get the same result with a MobileControl of a MobileWebForm?

    Thank you very much.

    Wednesday, September 5, 2007 7:23 AM

Answers

  • User-375488743 posted

    I understand what you say, but the attribute I need to include is "onClick" in a Command Control.

    I have tried what you propose but it does not work.

    Is not possible to add the onClick attribute in the way you say?

    Otherwise, I have found another solution:

    I put a Panel inside the Form, a Device Specific inside the Panel, and a System.Web.UI.WebControls.Button inside the Device Specific.

    Then, in the code behind I write:

     

    WebButton= CType(Panel.Content.FindControl("btnBuscar"), System.Web.UI.WebControls.Button)

    WebButton.Attributes.Add("onClick", "return validarDatos();")

     

    I found the solution here: http://forums.asp.net/p/1105749/1822232.aspx#1822232

    If it's possible to do the same with System.Web.Ui.MobileControls.Command, please tell me.

    Thank you very much.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 18, 2007 10:30 AM

All replies

  • User-375488743 posted

    The property Attributes does not exist in a Mobile Control.

    Wednesday, September 5, 2007 8:31 AM
  • User113421904 posted

    Hi, 

    Based on my understanding, you want to add custom attributes for ASP.NET Mobile Web Controls.

    MobilePage class has a property called CustomAttributes. By setting the Allow CustomAttributes property of the MobilePage class to true will allow all of the ASP.NET Mobile Web controls on the page to have custom attributes. Please see this URL for more information:

    Custom Attributes for Mobile Controls

    And here are two examples can show you how to add custom attribute in ASP.NET Mobile Controls:

    <mobile:TextBox id="Textbox1" runat="server" useRandomId="true"> </mobile:TextBox>

    Textbox1.CustomAttributes.Add("useRandomId", "true");

    This is from http://www.kbalertz.com/Q309518/Protect.Passwords.Devices.aspx

     

    Monday, September 10, 2007 10:52 AM
  • User-375488743 posted

    I understand what you say, but the attribute I need to include is "onClick" in a Command Control.

    I have tried what you propose but it does not work.

    Is not possible to add the onClick attribute in the way you say?

    Otherwise, I have found another solution:

    I put a Panel inside the Form, a Device Specific inside the Panel, and a System.Web.UI.WebControls.Button inside the Device Specific.

    Then, in the code behind I write:

     

    WebButton= CType(Panel.Content.FindControl("btnBuscar"), System.Web.UI.WebControls.Button)

    WebButton.Attributes.Add("onClick", "return validarDatos();")

     

    I found the solution here: http://forums.asp.net/p/1105749/1822232.aspx#1822232

    If it's possible to do the same with System.Web.Ui.MobileControls.Command, please tell me.

    Thank you very much.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 18, 2007 10:30 AM