C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » General »

Dynamically Hide/Disable controls in InfoPath 2003


Posted Date: 29 Aug 2006    Resource Type: Articles    Category: General
Author: Sidhartha GundavarapuMember Level: Gold    
Rating: 1 out of 5Points: 10



Introduction


Working on InfoPath form is an easy affair as long as, developers use it for the sole purpose of its creation (Creating a simple forms to capture data and publish them to a server for sharing). The moment this rule is broken, the increase in the complexity will be directly proportional to the features being implemented.

Problem and solution


There are situations where you may need to perform some action based on the currently logged in User, the role of the user or some other parameter.

Recently, I was working on something which required us to do some UI validations based on the user logged in. We cannot directly use the user roles provided as the user names will be stored in a database and we need to set the UI according to the user preferences.

This is not a straight forward task in InfoPath (though, I dont want to call it tedious aswell) as InfoPath does not work that way.

So, we had to work on several work arounds and found a very simple alternative.

In the attached sample, you can type in the any username in the user name textbox and the dropdown will be disabled as soon as the username is identified as the current windows username.

Pretty simple code... just look at how simple InfoPath makes things.


//OnLoad()
thisXDocument.DOM.selectSingleNode("//my:Alias").text = Environment.UserName;


you need to have a hidden control on the screen called Alias, and all the control for which we have to control the state should be using the Alias control to set the rules

Summary


Please get back to if you have any suggestions/comments/clarification regarding this topic. Write to me for the sample code for this article



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Infopath  .  Hide  .  Dynamic controls  .  Display  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Motivation Ideal Kit
Previous Resource: Microsoft Office 2003: Microsoft InfoPath 2003 Performance tuning
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use