ASP.net Dropdown selected Index changed

Hi

I am using Infragistics WebDatamenu in my webapplication

I am also using Master Pages in my application and calling other pages as required.
On my master page, there is a dropdown with user Roles populated.  there is another dropdown, contains Partner names,  which gets refreshed if user role is selected or changed on the same Master Page with associated partners.

I am using Infragistics Webdata Menu on remaining other pages such Invoices / customers etc.

When I select or change role from user role dropdown and before the Partner dropdown gets refreshed, if I click on Menu options, exception is thrown.

I want to disable the Menu options immediately after i select or change user role and until partner dropdown is refreshed.

How can I achieve this?

Please note: when I tried to capture Webdatamenu on selected index change event, master page didn't find webdatamenu i.e. returns NULL when I use Findcontrol method.

thanks in advance
LVL 1
Innovation SupportInnovation SupportAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

F IgorDeveloperCommented:
Try using jQuery in the "onchange" event you can disable all SELECT controls
until the page is refreshed.


$("SELECT").prop("disabled","disabled");
window.setTimeout('$("SELECT").prop("disabled",false);',10000);

Open in new window



Note that the user cancels refresh this controls will be disabled until he reloads the page
so the last line allows to re-enable the selectors in 10 seconds (10000 miliseconds) if the page is not reloaded
0
Innovation SupportInnovation SupportAuthor Commented:
Where should I write it? In .aspx?  and how should I call it in .aspx.cs on selected Index change event?
Not sure that's why asking.

Copied code (.aspx.cs from master page) below to clarify further
protected void ddUserRole_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {

             /// I was thinking of writing code here to disable once the user role is refreshed.
                
                DataBindRoleAndPartner(ddUserRole.SelectedValue.ToString());                                
                BindSummaryViewGrid(true);            

             /// I was thinking of writing code here to enable once the user role is refreshed.
            }
            catch (Exception ex)
            {
                _ErrorWindow("CANCEL", "Partner Details Error", ex.Message.ToString(), false);
            }                  
        }

Open in new window

0
F IgorDeveloperCommented:
See this page  (How to add client side script in forms)
https://msdn.microsoft.com/en-us/library/aa479302.aspx

Also you can modify the master page (html, not codeBehind) to add some SCRIPT block
Use instead of "#controlid" the id of current control ("#ddUserRole"?)

<script>
$("#controlid").on("change",function(){
   $("SELECT").prop("disabled","disabled");
   window.setTimeout('$("SELECT").prop("disabled",false);',10000);
  }
)
</script>

Open in new window

1
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Innovation SupportInnovation SupportAuthor Commented:
when I have added this code, it's throwing javascript exception

Microsoft JScript runtime error: '$' is undefined

the script I am using is as under:

 $(document.getElementById("ddUserRole")).on("change", function () {
         $("SELECT").prop("disabled", "disabled");
         window.setTimeout('$("SELECT").prop("disabled",false);', 10000);
     }


and the calling .aspx code:

<asp:DropDownList Width="210px" ID="ddUserRole" runat="server"  
                                                EnableViewState="true" Height="20px"
                                                onselectedindexchanged="ddUserRole_SelectedIndexChanged" AutoPostBack="True" onchange="onchange()"  
                                                 ></asp:DropDownList>


It's not working OR something I am not doing correct.
0
F IgorDeveloperCommented:
THis is done by using jQuery API  (you could include ths jquery js file in the <head> section of the master page.

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>

Open in new window



Also you could try without using jQuery (in "xxxxx" you need to replace with ID of the selector you want to disable) :


document.getElementById("ddUserRole").onchange=function() {
         document.getElementsByTagName("xxxxx").disabled=true;
         window.setTimeout('document.getElementById("xxxxx").disabled=false;', 10000);
     }

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Innovation SupportInnovation SupportAuthor Commented:
Thanks Fraigor, I will change and test accordingly.  I will let you know the results
0
Innovation SupportInnovation SupportAuthor Commented:
I will accept last answer as a solution, do not want to delete it as it could prove helpful in future
0
Innovation SupportInnovation SupportAuthor Commented:
I will accept last answer as a solution, do not want to delete it as it could prove helpful in future
0
Innovation SupportInnovation SupportAuthor Commented:
I will accept Fraigor's last answer as a solution
0
Innovation SupportInnovation SupportAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for Prafulla Shimpi's comment #a41703808

for the following reason:

Didn't find any option to select Fraigor as Best Solution
0
F IgorDeveloperCommented:
Hi, do you have problems accepting solution from last answer?
0
Innovation SupportInnovation SupportAuthor Commented:
Hi Fraigor, the web page is not giving me option to select your answer as Best Solution. How should i do it?
0
F IgorDeveloperCommented:
Since the question was requested for closing, i think the option was disabled.
I'll try to object your last request. Check soon if the option for accepting the answer is available again.
0
Innovation SupportInnovation SupportAuthor Commented:
Thanks Mr Wolfe and Mr Fraigor

Please give me some time, i will go through what I have implemented and will update here accordingly.
Regards
0
Innovation SupportInnovation SupportAuthor Commented:
Hi Mr Wolfe and Mr Fraigor

I have gone through What I have implemented.  

I am disabling my web data menu during dropdown refresh and enabling it once the refresh is completed. During refresh even if User clicks anywhere, it's not triggering any event.

Also thanks to the Mr Fraigor's suggestion which I will be looking into detail for further enhancements as what I have done is temporary work around
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.