views:

11

answers:

0

Hello to everybody.

Now i have create my first ASP.NET MVC Projekt. I think this is a good structure and a nice concept. But now i want to add some dynamic things.

My Problem is that i wanted to display 3 select boxes where 1 should be updated. Here is my code below.

<code>
<table width="100%">

<!--Headers-->
<tr>
<td><h4>Roles</h4></td>
<td><h4>Users in Role</h4></td>
<td><h4>All Users</h4></td>  
</tr>

<tr>
<% using(Ajax.BeginForm("StartUpdate",new AjaxOptions{UpdateTargetId="update"})) { %>
<td width="30%">

<select name="roles" id="roles" size="5" onchange="submitform.click()">

 <% foreach (var item in WebServer.Models.UserModel.getRoles()){ %>

       <option><%= item %></option>

    <% } %> 

</select>

</td>

<div style="visibility:hidden"><input type="submit" id="submitform"/></div>
<% } %>


<td width="30%">

    <div id="usersinrole" align="left">
    <select size="5" id="selectusersinrole" onchange="document.getElementById('users').selectedIndex = -1"><option>Please select a role</option></select>      
   </div>


</td>

<td width="30%">

<select name="users" id="users" size="5" onchange="submitform.click()">

 <% foreach (var item in WebServer.Models.UserModel.getAllUsers()){ %>

       <option><%= item %></option>

    <% } %>  

</select>


</td>

</tr>

</table>
</code>

My Questions are:

  1. I do the Submit for the Ajax form with a Button that is not display. Is there a better solution for that?

  2. If one value in the select box selectusersinrole is selected this should be deleted in the method. But every time if i check the Request.Form["selectusersinrole"] it is null and i dont know why.

  3. Another problem is when a value in the select box users is clicked the focus will not leave. I add the users on click in the select box in the method that i called. But when the form is refresh the select box has the focus that i dont want. Is it possible to do deselected on refresh?

I hope you unterstand my englisch....:-)

Best regards

bladepit