Javascript - Conditional Markup Rendering According To Web.config Key?
Jan 19, 2011
I have a key in web.config as -
<add key="IsDemo" value ="true"/>
I want to show/hide markup based on above web.config entry for a non-server html tag without using code behind file (as there is no .cs file and there are no runat=server controls).
Something similar to following pseudo code:
IF ( IsDemo == "true" )
THEN
<tr>
<td id="tdDemoSection" colspan="2" align="left" valign="top">
<.....>
</td>
</tr>
ENDIF
Does anyone know that we can write such conditional logic in .aspx markup? \
EDIT:
Section I'm hiding or showing have some data like username and password. So, I do not want user to use Firebug or Web Developer Tools to see hidden markup. markup should not go to client side.
View 3 Replies
Similar Messages:
Nov 25, 2010
Just to get it work, I got a controller action that make use of a switch statement to decide which partial view to render, based on one of the members of the model passed in. (Written by someone else for what it matter...I'm just cleaning up)
The viewmodel is overcomplicated, but that's not my decision right now and just have to live with it.
All partial's get rendered passing the same viewmodel, just a different partial get called.
[Code]....
View 5 Replies
Jun 6, 2013
Here is a snippet of the code that currently renders a panel on my asp.net page:
Code:
<asp:Panel ID="pnl4" runat="server" Visible="false">
<br /><br />
<b>Select one or more blah blah blahs</b><br/>
<asp:CheckBoxList ID="chkBlah" runat="server"></asp:CheckBoxList>
<br />
and then there's more strings and checkboxlists.
There is a new requirement that parts of the page be suppressed based on the date a user selects. So it was easy when it was like this:
Code:
<tr style="display:<%=DisplayThis%>">
<td class="label">X:</td>
<td class="labelValue" bgcolor="#ffffff">
<asp:DropDownList ID="dropX" runat="server"></asp:DropDownList>
</td> </tr>
and I had server code that set DisplayThis to none or block.
But what if it's just text that's hanging out? Should I turn the text into a label? I just want to make sure I'm doing it the right way, as this is someone else's code and I'm trying to respect it .
View 14 Replies
May 28, 2010
i've to display a messagge in my homepage (default.aspx) different for each "installation" of my web app. i would like to avoid to make a call to database to show this message.. so i've thougth to use web.config to store something like this
<add key="WelcomeString" value="lorem ipsus <b>doloret sit amen</b>" />
But i've noticed i can't use html markup into web.config Is there a better approach ? Or is there a way to insert html markup into web.config ?
View 3 Replies
Oct 30, 2010
I have an ASP.NET site which uses a 3rd party activeX control. I have to pass a few parameters to the OBJECT tag in the HTML page. If i hardcode these parameters into the HTML everything works.
I would like to place the parameters in my web.config with app settings "key/value" pairs.
My problem is i cannot read the app key setting in the HTML markup to succesfully pass them in as parameters. I can read them fine from server side code behind.
What's the correct way to read these settings in the client side HTML markup ?
View 4 Replies
Jul 13, 2010
I have a javascript src that i need to add to some of the pages in a site.
for example <script type="text/javascript" src="http:abcxyz.com/zzz"></script>
I want to add this conditionally on a .ascx page - if the Request.ServerVariables["SCRIPT_NAME"] ends with certain criteria.
The ascx language is vb, and there is no code behind.
View 2 Replies
Jul 21, 2010
I have a datagrid with checkboxes. User selects some rows and click on a button on the same page.
Code on button_click verify the data for selected rows, It it finds some certain status (Valid), I want a confirmation message to show "You have a or more valid record(s), Do you really want to set inactive?"
Now i user clicks ok, next code should execute else not.
I know attribute.add can not be used because it decides the condition on same button click.
View 8 Replies
Dec 22, 2010
I've been assigned changes to make to an ASP.NET project. The WebForm I'm working on needs to dynamically display and hide controls in response to user actions.
So far, so good. My approach would be to create a little JavaScript. However, on this page, the markup is part of a template for a Telerik control (which I know nothing about). I'm not sure the ramifications of this. Can I still use JavaScript for templated markup?
I tried to insert some existing JavaScript in the page. The first problem I have is my use of <%= ControlName.ClientID %>, which produces an error because the name of the control in the template is not seen to exist by ASP.NET.
Is there another way to do this, or am I just going to run into more problems?
View 1 Replies
Nov 15, 2010
I have a asp.net panel that is initially hidden and is shown when a button is clicked. There is javascript inside that panel and it doesn't execute after the panel is set to be visible. I can see that javascript function gets outputted on page but it is not called. What can I do to make it so that function gets called? Here is an example:
<asp:LinkButton id="lbtn" runat="server" Text="show" OnClick="lbtn_Click" />
<asp:UpdatePanel id="upnl" runat="server" UpdateMode="Conditional">
<contenttemplate>
<asp:panel id="pnlContent" runat="server" visible="false">
content initially hidden.
<script>
alert('done!');
</script>
</asp:panel>
</contenttemplate>
<triggers>
<asp:AsyncPostBackTrigger ControlID="lbtn"/>
</triggers>
</asp:UpdatePanel>
View 2 Replies
Feb 25, 2010
This might be confusing but ill try to explain the best as i can. I have a gridview that get the data from datatable. This is simulation my grid view.
key data
1 data1
2 data2
2. data2
2. data2
3. data3
3. data3
what i want is make some conditional statement, when value "key" is changed i want to add empty row. so its suppose to be looks like this as result.
key data
1 data1
EMPTY ROW
2 data2
2. data2
2. data2
EMPTY ROW
3. data3
3. data3
View 2 Replies
Mar 3, 2011
I have a user control.
On that user control is an update panel.
In that update panel is a wizard.
One of the steps is as follows.
[Code]....
What this does is create a javascript spinner control. Now when I click the NEXT button onto this step it generates the spinner control. I click next to go to the next step, then I click PREVIOUS to go back to this step and the spinner control is not generated.
Now I have tested this on an ASPX page and it seems to work, I then copy the code across to an ASCX control and put the page live and it does not work.
The update panel has an animation extender that just displays a div with a processing gif when you click next/previous.
So any reason why it creates the control on the next and not the previous step?
View 1 Replies
Nov 9, 2010
In web application, i tried scrolling the window vertically by increasing a y axis height to 500 with a javascript that is attached to OnClientClick event of a asp.net button control with id Button1. The script i have used is
<script language="JavaScript">
function scrollToWindow()
{
window.scrollTo(0,500);
}
</script>
and the button code is as follows
<asp:Button ID="Button1" runat="server"
Text="Scroll to bottom" OnClientClick="scrollToWindow()" />
If i run this page and click that button, the page scroll is not working properly. when i put alert inside that script and debug, i found that the page is actually scrolling to 0,500 but again its rendering to its normal position because of some reasons. Overcome this issue and let me know the reason behind that?
View 3 Replies
Apr 30, 2010
[Code]....
</script>
In the span's onclick handler i wrote "javascript: alert(getAppSetting('ftpuser'));" for testing, and built some alerts into the function. The first alert returns [object]. That's nice, i thought. The second alert returned 0. That's strange, because the web.config has exactly 1 of this node. So i guess that the function doesn't actually load the correct document. Has anyone done something similar ? When i don't suppy a full path, doesn't javascript assume that it should look for the file in the virtual directory of the current web application where the web.config is ?
View 3 Replies
Feb 8, 2011
When the user clicks on it, another .aspx page should pop up. I used the code below and it works fine. But when we deploy this .aspx page, the IP address of the target IIS server will be different. So I am thinking of saving the IP address of target IIS server in web.config file and load it into the Window.open method of Javascript code (below).Qusetion 1: Is that right way to do? If so, how I can read web.config file from Javascript?
Code:
<script type="text/javascript">
function open_win() {
window.open("http://10.999.1.86/WebUI/HistoricalRuns.aspx", "_blank", "toolbar=no, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, copyhistory=no, width=1000, height=500");
View 7 Replies
May 28, 2010
I want to redirect my Javascript and CSS URLs to Homepage(Default.aspx) by web.config or via anyother way in ASP.Net. I tried to try it but I can't able to do this thing. I have already checkout ASP.Net professional book but I can't get any reference for it anywhere.
View 2 Replies
Apr 30, 2010
Web.config is the main settings and configuration file for an ASP.NET web application. The file is an XML document that defines configuration information regarding the web application. The web.config file contains information that control module loading, security configuration, session state configuration, and application language and compilation settings. Web.config files can also contain application specific items such as database connection strings
Example 1:
<!-- This is an example Web.config file -->
[Code]....
In this article, we will see how to read the configuration settings in the web.config using 'JavaScript'.
Step 1: Create a new ASP.NET website. Add a button control to the Default.aspx.
Step 2: Right click the project > Add New Item > Web Configuration File
Add the following sample entry to the appSettings section in the web.config between the <configuration> tag as shown in the example 1:
<add key="var1" value="SomeValue"/>
Step 3: To read these entries using JavaScript, add the following script in the <head> tag of your Default.aspx page as shown below:
<head runat="server">
<title></title>
<script type="text/javascript">
function ReadConfigSettings()
{
var v1 = '<%=ConfigurationManager.AppSettings["var1"].ToString() %>'
alert(v1);
}
</script>
</head>
Step 4: Call this function on a button click and display the values of the configuration settings
<input type="button" value="Get" onclick="ReadConfigSettings();" />
That's it. Run the application and click the button. The value of the key in the appSettings will be displayed in the alert window. I hope you liked this short article.
View 7 Replies
Nov 5, 2010
I use LINQ.But I can not add data twice "ZnizanaDnevnica.
How could you do one box:
tbl_dnevnice_obracun tbl_dnevnice_obracun = new tbl_dnevnice_obracun()
{ZnizanaDnevnica = ((totDiffHours> = 6 & & totDiffHours <8)? Convert.ToDecimal (dt.Rows [0] ['Znizana']. ToString ()): 0),((totDiffHours> = 12
& & totDiffHours <24)? Convert.ToDecimal (dt.Rows [0] ['Znizana']. ToString ()
View 1 Replies
Dec 22, 2010
I've got a weird problem: On a page, i've 2 updatepanels in conditional updatemode, with childrenastrigger set to true (default value).
A click on a IPostBackEventHandler control inside either the first or second updatepanel causes the 2 updatepanels to refresh.
View 2 Replies
May 28, 2010
I have an ASP.NET web app (with C#). In it I have a form with several fields and validators. For one of the validators I only need to validate when:
a certain textbox is empty and a certain record does not exist in the database (this is already handled).
I know I can't enable/disable the validator on page_load because something might be entered into that textbox. I also tried the following in the onclick event of the submit button but it didn't seem to work:
Validator1.Enabled = true;
Validator1.Validate();
I also tried Page.Validate() but that didn't work either...
View 2 Replies
Aug 25, 2010
Is it possible to use a condition inside an actionlink ?I would like to do this :
[Code]....
This will be used for some column sorting and if the current sort was asc the next sort has to be desc. The code above is not valid while compiling.
View 3 Replies
Jan 6, 2011
Which of these will perform better if we assume that the IF block in #1 will be executed more and less in #2
foreach()
{
if
{
block here
}
}
or
foreach()
{
if !( )
continue
}
I've structured #2 to take the if conditional less often.
View 4 Replies
Dec 23, 2010
How do I properly write an if statement for t-sql in vb.net?
I have this code:
[Code]....
View 3 Replies
Feb 10, 2011
Is there any difference between below two statements
if (null != obj)
and
if (obj != null)
Edit: if both treated same which will be preferable?
View 7 Replies
Jan 19, 2011
I just installed VS2010 and opened the root machine.config and web.config files for review and I found some errors. In machine.config, the following line has errors in both entries for <Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior>. When I hover the cursor over them I get a tooltip text which displays: "The element 'endpointBehaviors' has invalid child element 'Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior'. List of possible elements expected: '...(list of options here)...'. The same problem happens for the second appereance in tag <serviceBehaviors>.
[Code]....
In web.config, there is a tag called <protocols> that has an error with a tooltip text that says "The element 'system.web' has invalid child element 'protocols'. List of possible elements expected: '...(list of options here)...'.
View 2 Replies
Feb 16, 2011
Currently, I work on an ASP.NET project which is hosted under version control and is used on several developer machines, tester machine and production environment.
In three cases, configuration (Web.config) may be different. For example, developer and tester environments use testing SQL Server, whereas in production environment, another SQL Server is accessed, so the connection string is different in those cases.
We want to keep three versions of Web.config in subversion. But modifying each of three files every time we need to add, remove or change a common setting is annoying: it would be nice to have a common, master Web.config, which will be inherited by each of the three Web.config files.
How to set up an ASP.NET project which will use a master configuration file and different slave configuration files on different machines, thus sharing the same project/source code/configuration files in subversion?
View 2 Replies