I am trying here to create a module linked to a webhosting cart process.
The first step should have a textfield with an "add" button. This button checks the availability of a domain and add it to a list.
The goal here is to basically display the list of domain verified and give proper action as radioboxes (register if it is free, transfert otherwise or point the domain directly).
So basically I check the availability and then add a literal control in a placeholder.
The problem with that is the viewstate (when I step forward and backward I lose the choices I had made with the domains).
the html :
( ... )
<asp:MultiView ID="mvFlow" runat="server" ActiveViewIndex="0">
<asp:View ID="vDomain" runat="server" onactivate="vDomain_Activate">
<asp:TextBox ID="txtDomain" runat="server" style="margin-bottom: 0px"
Width="254px"></asp:TextBox>
<asp:Button ID="domainAdd" runat="server" onclick="domainAdd_Click"
style="height: 26px" Text="Ajouter" />
<br />
<br />
<asp:PlaceHolder ID="phDomainResults" runat="server"></asp:PlaceHolder>
<br />
<br />
<asp:LinkButton ID="lbDomainSkip" runat="server" onclick="lbDomainSkip_Click">Prochaine
étape »</asp:LinkButton>
</asp:View>
( ... )
behind it's basically something like this :
lt.Text =
"<dl>" +
"<dt><strong>" + txtDomain.Text + "</strong> <span style='color:green;'>Le domaine est disponible</span></dt>" +
"<dd><input type='radio' name='" + txtDomain.Text.Replace('.', '_') + "_action' value='register' /> Register</dd>" +
"<dd><input type='radio' name='" + txtDomain.Text.Replace('.', '_') + "_action' value='transfert' disabled='disabled' /> Transfert</dd>" +
"<dd><input type='radio' name='" + txtDomain.Text.Replace('.', '_') + "_action' value='point' /> Point</dd>" +
"</dl>";
There must be possible to make things more logical and easy ?
Following suggestion I did this :
LiteralControl lt = new LiteralControl();
RadioButtonList rl = new RadioButtonList();
lt.Text = "<strong>" + txtDomain.Text + "</strong> <span style='color:green;'>Le domaine est disponible</span>";
rl.Items.Add(new ListItem { Enabled = true, Selected = true, Text = "Enregistrement", Value = "register" });
rl.Items.Add(new ListItem { Enabled = false, Selected = false, Text = "Transfert", Value = "transfert" });
rl.Items.Add(new ListItem { Enabled = true, Selected = false, Text = "Pointer moi même", Value = "point" });
//phDomainResults is a PlaceHolder in the page
phDomainResults.Controls.Add(lt);
phDomainResults.Controls.Add(rl);
Doesn't seem to work more...