0

I have to create a website on MVC 3 but i am restricted not to use JavaScript at all...

All of the stuff i found for MVC is implemented through JQuery. I am in search of the solution that helps me to implement My MVC website without jquery.

I have 3 dependent drpdownlists Country , State and City. On Counties List Selection Changed States will be filled with respect to selected country and so on. Although i have done this using Jquery successfully But now i have to d0 this without jquery and the second solution i got is to define an input button to fill child list but of course it is not a good solution too.

Can i define an event in MVC 3 like we do on aspx pages for Dropdown selection change ??

Any help would be highly appreciated...

3
  • 1
    I'm not sure I understand you, but I think any reasonable solution will require some client side scripting, otherwise you're going to have to split this up over several pages/page loads. Commented Jul 7, 2011 at 8:38
  • the above comment is incorrect - please see my answer below - it allows you to have more than one submit button on a single form - each posting to it's own action i.e. public ActionResult Index_DropDown1Selected() Commented Jul 7, 2011 at 8:47
  • @Roul: So it seems like Jquery/JavaScript is compulsory for MVC .So in case when web user will disable the scripting then what will we do?? Commented Jul 7, 2011 at 10:40

3 Answers 3

2

You would need to have a submit button to push the form to the server to then render the second dd in the cascade. to have more than one submit on a form use the method i blogged about here:

http://blogs.sonatribe.com/wayne/2011/06/15/171/

Sign up to request clarification or add additional context in comments.

1 Comment

Thanx for the response. But i don't want to use a submit button that'll work jsut for filling child list. as we do it using jaquery onchange function can we do something like this with out using jquery..
0

The "change" event in ASP.NET WebForms DropDownList control uses Javascript to cause a postback to the server when you have AutoPostback set to true. If you can't use Javascript at all, you will have to submit the form through a standard submit button.

Usually the requirement is to make the application work without Javascript, but to use Javascript to provide a richer experience for users with browsers that support it. I think that's more sensible than to not use Javascript at all.

Comments

0

This has nothing to do with MVC or ASP.Net.

If you want your browser to react to input like you describe it, you need JavaScript, independent of the underlaying server side platform.

If your question is: "Can I get the functionality ASP.Net controls provide, like the Postback, without writing JavaScript myself." But you are allowed to use JavaScript, just not write it yourself.

You could probably find some controls for MVC that keep the JavaScript out of sight. But MVC is not the platform for that. It is developed to give the developper close control over the Html (and JavaScript) that is created. So you will probably have to write Javascript yourself anyway.

BTW: You can totally use ASP.Net or Asp.Net MVC without using javascript, and create a functional Website.

7 Comments

If it is possible without using javascript then how can i do it.Can you please tell me its solution
If your restriction is "do not use JavaScript", then you just cannot create a UI like you described. My point is: your UI has nothing todo with the server side infrastructure. ASP.Net does not force you to use JavaScript. But your requirements on the UI force you to use it.
But this is a very casual scenario and quite easy to perform in Asp .Net then why not in MVC ??
If you use the default Asp.Net controls, and you look at the source of the html-page, you will see it uses JavaScript. Did you run it in a browser with Javascript turned off?
@GvS yes you can - standard HTML forms have a submit button specifically for this purpose. @syeda Old style webforms would break under a non JS environment - why do you think they sucked so much? the method i have given you IS the only way you will achieve this.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.