ascx

ASP: ontextchanged not firing

僤鯓⒐⒋嵵緔 提交于 2020-01-25 04:22:12
问题 Note: I am brand new at ASP.NET. I'm actually going to training on Monday, but we have a hot project that required me to dive in and get done as much as I can. I've got a textbox on my page, and I would like it to call an event on the server whenever it is changed. I don't care if "changed" means changed and loses focus, or just whenever a keyup happens. Either case will work. The issue is that, for some reason, whenever I change my textbox and then remove focus, the server-side method is not

Storing ascx in database

跟風遠走 提交于 2020-01-04 08:15:22
问题 I would like to store the ascx control code into a database. Then rather then load the control from a filepath location, I would like to retrieve it from the database and load it into the UserControl. The UserControl.LoadControl only has two overload options. Without saving the control from a database to a temporary file and then load from the temporary file, is it possible do this direct from the database? 回答1: Can you use ParseControl instead? Link to MSDN. The method accepts a string that

How to call an ASP.NET WebMethod in a UserControl (.ascx)

那年仲夏 提交于 2019-12-29 04:28:28
问题 Is it possible to place a WebMethod in an ascx.cs file (for a UserControl) and then call it from client-side jQuery code? For some reasons I can't place the WebMethod code in an .asmx or .aspx file. Example: In ArticleList.ascx.cs I have the following code: [WebMethod] public static string HelloWorld() { return "helloWorld"; } In ArticleList.ascx file there I have the call to the WebMethod as follows: $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", data: "{}",

How to call an ASP.NET WebMethod in a UserControl (.ascx)

纵饮孤独 提交于 2019-12-29 04:28:15
问题 Is it possible to place a WebMethod in an ascx.cs file (for a UserControl) and then call it from client-side jQuery code? For some reasons I can't place the WebMethod code in an .asmx or .aspx file. Example: In ArticleList.ascx.cs I have the following code: [WebMethod] public static string HelloWorld() { return "helloWorld"; } In ArticleList.ascx file there I have the call to the WebMethod as follows: $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", data: "{}",

How to run off ASP.NET validation for aspx in VS?

三世轮回 提交于 2019-12-25 04:28:05
问题 I have an ascx control named PicView in a classic ASP.NET 4.0 project. The beginning of it looks like this: <script runat="server"> Public ImageUrl As String , meaning that we can use the control's ImageUrl property in aspx pages. To use the control, I add the following directive to an aspx page: <%@ Register TagPrefix="x" TagName="PicView" src="~/ascx/PicView.ascx" %> , and then later in the body of the aspx use the control like this: <x:PicView ImageUrl="img/bla-bla.jpg" runat="server" />

Need to reference Usercontrol(ascx) in ASPX page in more than one place with different results

百般思念 提交于 2019-12-24 23:59:17
问题 Scenario : Default.aspx is as below. <%@ Page MasterPageFile="~/StandardLayout.master" Language="C#" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register src= "~/Controls/Us.ascx" tagname="AboutUs" tagprefix="site" %> <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server"> <div id="large"> <site:AboutUs ID="AboutUsControl" runat="server" /> </div> <div id="small"> <site:AboutUs ID="AboutUsControl" runat="server" /> </div> </asp:Content> AboutUs.ascx.cs assigns

Allow .ASPX page to display before .ASCX control finishes loading?

て烟熏妆下的殇ゞ 提交于 2019-12-24 10:51:10
问题 I have an ASP.NET page with one control (.ascx) on it. The page (.aspx) onload assigns some text to a couple labels and passes a product ID to the .ascx control. The .ascx control, onload, takes that product ID from the .aspx page and hits the database several times, does several calculations, etc - basically takes a long time to load. So when I'm clicking a link to this .aspx page, it is taking 7-10 seconds for the page to load. I've narrowed it down to the calculations on the .ascx control

ASP.NET ListView with identical markup in EditItemTemplate and InsertItemTemplate

六眼飞鱼酱① 提交于 2019-12-22 00:27:03
问题 I have a ListView that includes an EditItemTemplate and an InsertItemTemplate. The two forms share almost all of their markup. For example: <asp:listview runat="server" ... > <layouttemplate>...</layouttemplate> <itemtemplate> <p><%#Eval("Name")%></p> <p><%#Eval("Title")%></p> ... </itemtemplate> <insertitemtemplate> <p>Name: <asp:textbox runat=server text='<%#Bind("Name")%>' /></p> <p>Title: <asp:textbox runat=server text='<%#Bind("Title")%>' /></p> ... <asp:button runat=server commandname=

How to use javascript in .ascx pages

我们两清 提交于 2019-12-21 12:32:31
问题 How to use javascript in .ascx pages 回答1: You can add script tags to the markup: <script type="text/javascript"> // place your javascript here </script> <script type="text/javascript" href="path to js file" /> Or use ScriptManager in the code behind so you don't include the same file/js section multiple times if you use multiple controls in a page. You can find out more about ScriptManager here (overview, including usage scenarios). 回答2: I'm assuming that you included the JavaScript code

ASP.NET Is there a better way to find controls that are within other controls?

本秂侑毒 提交于 2019-12-17 06:54:11
问题 I currently have a dropdown inside an ascx control. I need to "find" it from within the code behind on another ascx that is on the same page. It's value is used as a param to an ObjectDataSource on ascx #2. I am currently using this ugly piece of code. It works but I realize if the conrtol order were to change or various other things, it wouldn't be where I am expecting. Does anyone have any advice how I should properly be doing this? if(Page is ClaimBase) { var p = Page as ClaimBase; var