ASP: button to input submit

1k views Asked by At

I am trying to use literalcontrol to add a button as input type="submit"

litLevelList.Text += string.Format(" &lt input type='submit' id='{0}' value='{1}' name='{2}' >", btnSave.ClientID, Lang.Trans("Save Changes " )  , btnSave. ??);

I could get the button ID using CLientID but without the name the data doesnt seems to be submitted.

Could anyone tell me how i could access the name value rendered by ASP for a button control.

thanks, vishnu

1

There are 1 answers

1
djeeg On BEST ANSWER

If you really must build the control, try using a HtmlGenericControl or a PlaceHolder control

http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlgenericcontrol.aspx

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.placeholder.aspx

UPDATE

This works for me:

    LiteralControl txtText = new LiteralControl();
    txtText.Text = "Something";
txtText.Text += "<input type='submit' text='Okay' id='" + btnSave.ClientID + "' name='" + btnSave.UniqueID + "'>"; 
    PlaceHolder1.Controls.Add(txtText);