hi,

     i have register form containing 3 partial views,so i am getting
these forms by selecting dropdown.

my dropdown code in Register form like this ::

<script type="text/javascript">
    $(function() {
        $("#UserRoles").change(function() {
        var selectedItem = $(this).val();
             $.getJSON("<%=Url.Action("FetchData")%>/?dropdownValue="
+ selectedItem,function (dropdownvalue) {
             alert (dropdownvalue)
            });
            if (selectedItem == "" || selectedItem == 5) {
                $("#CA").hide();
                $("#IND").hide();
                $("#PU").hide();
            }
            else if (selectedItem == 1) {
                $("#CA").hide();
                $("#IND").show();
                $("#PU").hide();
            }
            else if (selectedItem == 2 || selectedItem == 3) {
                $("#CA").show();
                $("#IND").hide();
                $("#PU").hide();
            }
            else if (selectedItem == 4) {
                $("#CA").hide();
                $("#IND").hide();
                $("#PU").show();
            }
        });
    });
</script>

 <%=Html.DropDownList("UserRoles", TryCast(Session("UserRoles"),
SelectList))%>

<div style="display:none" id="CA">
                    <%Html.RenderPartial("~/Views/Account/
RegisterPartialViews/CompaniesandAgencies.ascx")%></div>


                <div style="display:none" id="PU">
                 <%Html.RenderPartial("~/Views/Account/
RegisterPartialViews/Publisher.ascx")%></div>
                <div style="display:none" id="IND">
                    <%Html.RenderPartial("~/Views/Account/
RegisterPartialViews/Individual.ascx")%></div>
               </div>

In my controller::



  Public Function Register() As ActionResult


        Dim list As New List(Of SelectListItem)
        list.Add(New SelectListItem With {.Value = "", .Text = "--
Select--"})
        list.Add(New SelectListItem With {.Value = 1, .Text =
"Individuals"})
        list.Add(New SelectListItem With {.Value = 2, .Text =
"Companies"})
        list.Add(New SelectListItem With {.Value = 3, .Text =
"Agencies"})
        list.Add(New SelectListItem With {.Value = 4, .Text =
"Publisher"})
        list.Add(New SelectListItem With {.Value = 5, .Text =
"Shopper"})

        Session("UserRoles") = New SelectList(list, "Value", "Text")
        ViewData("PasswordLength") = 6
        Return View(New RegisterModel)
    End Function

    <AcceptVerbs(HttpVerbs.[Get])> _
Public Function FetchData(ByVal dropdownValue As Integer) As
ActionResult
        ' This action method gets called via an ajax request
        Return Json(dropdownValue)
    End Function


 Public Function Register(model as registermodel) As
ActionResult                       ''''''create button hits this
function
 If Not ModelState.IsValid Then
              Return View()
''''''''''validation fires & returns to this url 
http://localhost:2018/Account/Register
        End If
end function

My problems are ::

1) if i select "individual" from dropdown it will show the
correspondent partail view then iam click on create button , that
function sends to  main page(http://localhost:2018/Account/Register) .
my partial page cannot appear on page. if i remove

 Return View()     in post method of register gives empty page.. how
can i over this problem?


2)if i select "individual" from dropdown it will show the
correspondent partail view then iam click on create button,
validations fires for all controls in other partial view pages
also..how can i do validations for my selected values from
dropdown????



3)In script ::: i tried to get dropdown value in My to URL, but i
cannot..present script does not give alert in the

  $.getJSON("URL", data,callback)...here what is exactly data...how
can i write function(data) in to my page??

Thanks in Advance

Reply via email to