<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Browser Forms</title><link>https://www.infopathdev.com:443/forums/40.aspx</link><description>For browser form specific questions</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Hide Any Control On A Web Enabled Form ~ an Easy Alternative Way</title><link>https://www.infopathdev.com:443/forums/thread/50462.aspx</link><pubDate>Fri, 08 Jan 2010 20:35:55 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:50462</guid><dc:creator>turfnsurf4me</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/50462.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=40&amp;PostID=50462</wfw:commentRss><description>&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;strong&gt;The following is predicated on&amp;nbsp;having a web enabled form with&amp;nbsp;code behind ( c# )&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;font face="Times New Roman" size="3"&gt;Had the need to hide a button control on my web enabled form. I reviewed various articles and posts from the internet and frankly found them (although useful in their own right and I respect the people that volunteered the information)&amp;nbsp;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;&lt;u&gt;way&lt;/u&gt;&lt;/strong&gt; too much trouble for my tastes. I figured&amp;nbsp;there just had to be a simpler way to do this, &lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;well for me at any rate. And to my delight I did find a way, only 8 lines of code!...woohoo!&lt;/font&gt;&lt;/p&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;strong&gt;Brief summary of what&amp;#39;s needed....&lt;/strong&gt;&lt;/font&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;/font&gt;&amp;nbsp; 
&lt;ul&gt;
&lt;li&gt;
&lt;div class="MsoListParagraphCxSpFirst" style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;mso-list:l0 level1 lfo1;"&gt;&lt;font face="Times New Roman"&gt;&lt;font size="3"&gt;1 Textbox&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;mso-list:l0 level1 lfo1;"&gt;&lt;font face="Times New Roman"&gt;&lt;font size="3"&gt;Some conditional formatting on the button&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div class="MsoListParagraphCxSpMiddle" style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;mso-list:l0 level1 lfo1;"&gt;&lt;font face="Times New Roman"&gt;&lt;font size="3"&gt;8&amp;nbsp;lines of code&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div class="MsoListParagraphCxSpLast" style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;mso-list:l0 level1 lfo1;"&gt;&lt;font face="Times New Roman"&gt;&lt;font size="3"&gt;5 minutes of my time without having to mess with Form Data Connections&amp;nbsp;and or other web services etc.&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;Done!....Wahla&amp;nbsp;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;strong&gt;&lt;u&gt;The Details&lt;/u&gt;&lt;/strong&gt;&lt;/font&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;/font&gt;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;strong&gt;1)&lt;/strong&gt;&amp;nbsp; Placed a textbox on my form. Set the conditional formatting to hide the textbox. Named the textbox &lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;txtHideFlag&lt;/font&gt;&lt;/p&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;(&lt;strong&gt;optional&lt;/strong&gt; )&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;In the web.config file of the Sharepoint site of where my form resides, I added a Key Value pair variable that would contain the domain user names for people I only wanted to see the button on the form. I did this so I could easily change the names of peoples who were only required to see the button. Rather than hardcoding usernames in the code base, and then having to recompile, re-publish / deploy and so forth. &lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font face="Times New Roman" size="3"&gt;Under &amp;lt;appSettings&amp;gt; in the web.config I added….&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;strong&gt;&amp;lt;add key=&amp;quot;SecurityManagers&amp;quot; value=&amp;quot;danb;stevek&amp;quot; /&amp;gt;&lt;/strong&gt;&lt;/font&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp; Obviously you&amp;#39;re going to add the domain users of your domain.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;strong&gt;2)&lt;/strong&gt;&amp;nbsp;&amp;nbsp;Include System.Configuration to your code base&lt;/font&gt;&lt;/p&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;blockquote&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;strong&gt;Using System.Configuration&lt;/strong&gt;;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;Then in my forms FormEvents_Loading() function I added the following code....&lt;/font&gt;&lt;/p&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;XPathNavigator root = MainDataSource.CreateNavigator();&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;string &lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;_securityManagers = &amp;quot;&amp;quot;;&lt;/font&gt;&lt;/p&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;if (&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;ConfigurationManager.AppSettings[&amp;quot;SecurityManagers&amp;quot;&amp;#39;] != null ) &lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;{&lt;/font&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font size="3"&gt;&lt;font face="Times New Roman"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _&lt;/span&gt;securityManagers&amp;nbsp; =&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;ConfigurationManager.AppSettings[&amp;quot;SecurityManagers&amp;quot;&amp;#39;]&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;if(&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;! _securityManagers.Contains( this.Application.User.UserName ) )&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font size="3"&gt;&lt;font face="Times New Roman"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;root.SelectSingleNode(&amp;quot;//mytxtHideFlag&amp;quot;, NameSpaceManager).SetValue(&amp;quot;HIDE&amp;quot;);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;else&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font size="3"&gt;&lt;font face="Times New Roman"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;root.SelectSingleNode(&amp;quot;//mytxtHideFlag&amp;quot;, NameSpaceManager).SetValue(&amp;quot;&amp;quot;);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&lt;/font&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&lt;font face="Times New Roman" size="3"&gt;I then configured the button&amp;#39;s conditional formatting to hide itself if the mytxtHideFlag textbox = &amp;quot;HIDE&amp;quot;.&amp;nbsp; So the logic / functionality is, if the domain user who is viewing the form in the web browswer, &lt;strong&gt;&lt;u&gt;is&lt;/u&gt;&lt;/strong&gt; contained in that list of usernames contained in the Key/Value variable ~(&amp;nbsp;in the web.config) ~, the button will be visible. Otherwise, the button is hidden.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt 0.25in;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>