dimanche 6 novembre 2016

ASP.NET accessing an Element created by C#

I have a masterpage and this master page is creating a code depending on some variables. the problem is i cant access the created controls from a contentsite

MasterPageCode: ` master_navigation_hori.Controls.Add(new LiteralControl(@"<li class='floatright' id='login'>
                    <a id='login-trigger' href='#'>Log in <span>▼</span> </a>
                    <div id='login-content'>
                    <fieldset id='inputs'>
                        <input id='input_username' runat='server' type='email' name='Email' placeholder='Your email address' value='test' required='required'/>   
                        <input id='input_password' runat='server' type='password' name='Password' placeholder='Password' required='required'/>
                    </fieldset>
                    <fieldset id='actions'>
                        <input type='submit' id='sub_login' runat='server' value='Log in' />
                        <label><input type='checkbox' id='staylogin' runat='server' checked='checked'/> Keep me signed in</label>
                    </fieldset>
                    </div>                     
                </li>"));`

So now this should create on the contentpage some inputs labels etc. but how du i access them now? e.g. I want to access the input_username so i go to my contentsite to the c# code typing input_username.Value but c# says that its not declared.

but when I debug the code and do a show site content in firefox then I can see that the code is created correctly and the id and runat server is also there.




Aucun commentaire:

Enregistrer un commentaire