This topic is locked
[SOLVED]

 Show / Hide page controls

9/4/2015 9:41:29 PM
ASPRunner.NET General questions
jadach authorDevClub member

Hello. I am new to MVC and C#. My background is ASP.Net Webforms and VB.net.
On an add or edit page I am trying to show or hide 2 fields based on the value of a dropdown selection. Has anyone done this using ASPRunner.Net?
Thanks

T
Tim 9/5/2015

Hello jadach. I have done this before (although I am not a programmer; ASPRunner makes me look like I am <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=77814&image=1&table=forumreplies' class='bbc_emoticon' alt=';)' /> Here is how I've done it:
In the "JavaScript OnLoad event" of the add or edit page in question, do something like this:
var cat = Runner.getControl(pageid, 'Category');

var c = Runner.getControl(pageid, 'Client');

var i = Runner.getControl(pageid, 'InfoType');
pageObj.hideField("Client");

pageObj.hideField("InfoType");
cat.on('change',

function(){ if (this.getValue() == '1'){

pageObj.showField("Client");

pageObj.showField("InfoType");

}

else{

pageObj.hideField("Client");

pageObj.hideField("InfoType");

}
});
Here is have 3 fields, Category, Client, and InfoType, which I create variables for.

Then I start by hiding 2 of them.

Then, when the user changes the Category dropdown list, if the selection equals the number "1" then I show the other 2 fields. Otherwise I hide them.
And here is a link to the help manual that gives an example and is where I learned how to do it:

http://xlinesoft.com/asprunnernet/docs/show_dropdown_list_of_us_states.htm
Hope this helps. Good luck!

Tim

jadach authorDevClub member 9/6/2015

Tim, thank you so much for this. It worked perfectly. I am going to have to get used to using JavaScript I guess <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=77817&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' /> I've used ASPRunner a number of years ago and I did some great things with it. ASPRunner.Net is a bit different regarding the syntax for events. I am confident it will get easier the more I use it and test things out. Again, thank you!

jadach authorDevClub member 9/6/2015

OK, now I am stuck again. I want to add 2 more scenarios. Using your example, how would it look if I wanted different fields to show for a value of 2, then different fields again for a value of 3.

Thanks

jadach authorDevClub member 9/6/2015



OK, now I am stuck again. I want to add 2 more scenarios. Using your example, how would it look if I wanted different fields to show for a value of 2, then different fields again for a value of 3.

Thanks


Ignore this. I wasn't patient enough. I figured it out. Thanks again.

T
Tim 9/12/2015

Hey jadach,
Glad you were able to get it to work. I too used to use ASPR Pro and switched to ASPR .Net last year . It does take a bit to get used to the different syntax, but I'm very glad I made the switch. The .Net applications are much quicker and somehow just feel more modern. One thing to note is that the Javascript is the same between both versions and is needed anytime you want to do something on the client side.
Glad to have another ASPR .Net programmer out there (we're a little out numbered by the PHP users, if you did't notice). ASPR has really changed my work life and allowed me to create some pretty great applications.
Tim

jadach authorDevClub member 9/13/2015

Yes, Tim, we are very much out numbered. Nothing would make me happier than to see this forum for ASR.Net pick up. I am actually very surprised there isn't more activity here.
I'm sure you will be hearing from me again. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=77857&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />