Conditional Javascript In .ascx?
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
Similar Messages:
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
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
Feb 3, 2011
I've looked at about 5 Questions here on SOF and haven't really found a useful answer for this. How am I supposed to invoke my javascript functions from client-side events in my .ascx controls? Here is my .ascx file.. what most the answers have led me to:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UIMenu.ascx.cs" Inherits="controls_UIMenu" %>
<script language="javascript" type="text/javascript">
function insetItem(myMenu)
{
myMenu.setAttribute("class", "myClass");.......
I'm getting different errors when doing it this way. ".....ascx does not contain a definition for "insetItem"", and my other pages that use this file don't recognize it anymore. When I try to put the js on the actual .aspx pages that will be using it, I get the same no definition error.
I just started learning jscript, still pretty noob. I'm trying to make it so when the user down clicks a menu item, I want that item's borderstyle to change to "inset". I'm not sure how to change that attribute for the specific item that gets clicked either in javascript >_< but that's another question.
View 3 Replies
Sep 24, 2010
How to use javascript in .ascx pages
View 2 Replies
Feb 17, 2011
So the problem is the following :
i do have own user control. which has some javascript file in script tag included like this
<script type="text/javascript" src="../somefile.js" ></script>
or some javascript code directly on the ascx page. everything works if i place this control somewhere in aspx markup. but if i add this control to the page dynamically to some UpdatePanel place holder on postback (this is logic i can not alter), control renders itself and then i get js error message, which says that functions which are placed in somefile.js are not defined/are null. Why is this happening ? Is there anyway to force js including in this case.
the code amount is huge and i was not able to provide a simplified example with the same error,.
The script is included but somehow the functions are not defined. I'm novice to js, so is it possible that just the script is included but not executed, so the functions are not declared ???
The interesting is that if on some page my custom control is declared in aspx.
View 3 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 understand how to use jQuery to make an AJAX call to a WebMethod from a normal page, but I'm running into problems doing it from a UserControl (ASCX). Right now the biggest Issue I'm having is that the JavaScript for getting access to the groupDropDown control is not working. It seems that since this is a UserControl hosted within DotNetNuke, the ususal method of getting the CLientID is not working since it is nested down x number of levels. Here is what I have:
Javascript:
function validateEnrolledDate(src, args) {
var isValid;
[code]....
I'm now just referencing a TextBox:<asp:TextBox ID="dealerId" runat="server" CssClass="theDealer" />
The Text in the Textbox is being set in Server Side code, and it is visible on screen.The alert message is "undefined", so something is still happening so that it is not getting the value of that textbox...
View 1 Replies
Dec 16, 2010
I am working on a feature to throw a warning message if the user has unsaved values in a form. I can see that in the next post there is a explanation about how to do that [URL]now the problem is that i need to do the same but using a ascx control and i don't know where put the next code in my ascx control.
<body onunload="checkSave()">
NB: I'm working on dnn so that i don't have any change to add this code in the parent page of the control.
View 2 Replies
Aug 10, 2010
I have to build a few ascx partial views in my MVC applications to encapsulate re-usable functionalities as well as archive SOR and SOC. However, I encountered challenge how to encapsulate the business logic that drives MVC ascx views.In webforms, the code behind of an ASCX control can handle a button click event and browser still shows the same page with only one postback. How can I archive the same thing in MVC? When ~/Address/Edit/2 includes an ascx partial view with a button on it that calls another MVC action - let's say ~/ShareController/CommonAction - what is the best way for the CmmonAction to return to the very same view that includes the ascx file?Perhaps I am missing a common pattern in MVC web development?
View 5 Replies
Nov 11, 2010
I am getting required functionality when I am adding javascript to grid column in aspx page. but i am not getting the same functionality when l am loading ascx page in my aspx page.
View 6 Replies
Jun 2, 2010
I have a user control (ascx) which contains a control (hidden field). In the page_load event of ascx, i have the below code:
HyperLink.Attributes.Add("onclick", "JavaScript:return AccessControl('" + hdnField.UniqueID + "');");
Note: The hidden field resides in .ascx file.
I want to access this hidden field at runtime and i have the below javascript function in aspx page that loads the usercontrol.
function AccessControl(hdnFieldId)
{
var ctrl = document.getElementById(hdnFieldId);
alert(ctrl);
I am getting 'null' value in the alert. I tried using 'ClientID' and 'this' instead of 'UniqueId'. I am wondering why this is not working. I am using .net 2.0.
View 1 Replies
Aug 2, 2010
I have an ASCX component that has a lot of javascript declared in a script tag in the ascx itself. I can set breakpoints, and the debugger stops as it should, but the text that is highlighted in the debugger as the "current line" is nowhere near the actual javascript (it is much higher in the rendered file than it should be). I can "wing it" for one or two lines with the real code side-by-side with the "false" line of execution, but I lose all the hover abilities and everything else that makes javascript debugging useful.
I have tried putting the script at the top of my ascx file, but to no avail. I've tried not setting a breakpoint until the entire page is rendered, so that I have to scroll all the way to where the actual lines of code are, and the debugger still stops somewhere way above it.
View 1 Replies
Apr 14, 2010
I am having difficulties how to construct my question, but if I have to put it simply the situation is that I have categories of products. I have an aspx with a repeater on the left that lists the categories. And I want the products to be listed on the right. Category number is variable so I made an ascx with a DataList in it. When I try to do foreach category, ascx = new ascx(); then the DataList within this ascx control is null.
ps: what I want to do is to preload all the products (thre is not much) and hide the divs and fadein fadeout them using jQuery when a category div is clicked.
rightnow it is using jQuery.load(); and I don't like how the images load, cuz they download from top to bottom. Progressive gifs alsdo not an option. site demo is here [URL]
View 1 Replies
Mar 16, 2010
I'm developing second language support for the site. So I made duplicate .ascx and .aspx files for existing ascx.cs and aspx.cs
Most of the time everything works fine.. but suddenly I'm getting:
Type 'ctrl_car' exists both in 'c:WindowsMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Files
zhdengined072cc729d5698bApp_Web_xdmblegv.dll', and in 'c:WindowsMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Files
zhdengined072cc729d5698bApp_Web_gkptrzo2.dll' (translated from russian)
ctrl_car ctrl = (ctrl_car) LoadControl("car.ascx");
I have few such strings of code... and same error occurs with one of them. But WITHOUT any changes from me with those files. To fix thaat bug for some time I need to delete solution and website folder and reget them from SS. Solution was converted from vs2005.
View 3 Replies
Oct 8, 2010
I have written a web usercontrol (ascx). Inside, there is a Panel that I want to show/hide on click of a hyperlink inside the usercontrol.
Normally, this is easy just by doing something like this (the onclick attribute is added to the hyperlink on prerender):
var PanelToShow = document.getElementById('<%=PanelInvoiceHasBeenCreated.ClientID %>');
if (PanelToHide != null) {
PanelToHide.style.display = 'none';
}
but because the ascx control is held within the gridview, the above will assess all the controls (of which there are many in the gridview) with the name 'PanelInvoiceHasBeenCreated'. The only time it will work is when there is 1 row in the gridview. Currently, with my existing code, if I click the hyperlink in any row, it shows/hides the panel in the bottom row of the gridview!
Therefore, my question is how do I get the actual, unique ID I need to show/hide on the correct control in the correct row?
View 2 Replies
Sep 16, 2010
i have made a BaseUserControl.ascx and a ChildUserControl.ascxfile. both have its own code behind file.So what i want, i wanted to inharit ChildUserControl.ascx fileto BaseUserControl.ascx. so whatever in my BaseUserControl.ascx fileshould be visible into the ChildUserControl.ascx,means if i have kept a TextBox in BaseUserControl.ascx should be visibleinto the ChildUserControl.ascx desing view. and it should be accessible into the ChildUserControl.ascx code behind file.
1) Is this possible, if yes then how?
2) if above is possible then How to access BaseUserControl.ascx code behind file into the ChildUserControl.ascx code behind file?
View 3 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 3, 2010
I want to know how I could fix the following. I essentially have two almost identical SQL functions and want to combine them into one. The only difference between the two functions is the SQL Command text that is being used. Here is a brief idea of what I have unsuccessfully tried thus far:
[Code]....
I receive no compilation errors, but the exception is thrown and table is not filled. I have a feeling that I am overlooking something obvious.
View 3 Replies