I have a web page that I am converting from classic ASP to ASP.Net. There are a bunch of "Select" controls (DropDown Boxes) that I am changing to DropDownList controls. I have set the "runat='server'" in all of these controls. However, when I go to the code-behind, they are not visible/accessible. I have tried to "clean" the solution and rebuild it and the controls still won't show.
i'm using VS2005 and when i drag and drop an image button, i can't access it from code behind. the following is an example of an unaccessible imagebutton
I have a page that i created a few weeks back.. had a few controls on the page.. everything worked and works great. Now this past week we had to me some changes to the page, adding a few more controls to the page.. the issue is that now, all the new controls.. (standard .net controls within VS2008) are not accessible from the code behind..
Example, if i add a textbox today to the page.. when i go to the code behind and begin to type textbox1. intellesense doesnt do anything.. and if i complete the line i get a wavy line under it..
In order to gain access to the textbox i have to add this to the code behind
I have a PlannerShiftView user control in the root folder of my ASP.NET web site. In my App_Code folder, I have a ShiftViewTemplate class that needs to instantiate a PlannerShiftView (for a TemplateField in a GridView). The problem is, the following code doesn't compile because the PlannerShiftView type is not available in what I deem to be the App_Code 'phantom namespace'.
Please can somebody explain to be what is happening here, as well as what to do. I know I can just move the ShiftViewTemplate out of App_Code, going against convention and without explantion, but that is something of a hollow victory.
i have defined profile properties in my web config file but unable to access them in code behind. even profile object is not available. i have to writer fully qualified name like System.Web.Profile. below is my web config
After much research, no solution can be found to do what I want by combining these two controls. Currently, I have a repeater control which, in page_load, takes the querystring and queries the database accordingly, puts the resulst in a datatable, and binds the datatable to the repeater. Everything works fine, no problem there. It's just that I have many columns coming from the query and there are many rows as well. So, I thought it would be easier to incorporate the accordion, so that the header of each accordion pane would show some unique fields (name, whatever...) as the header, and the rest of the many fields in the content. This way, there would be many closed accordion panes showing the name from the row returned. If the pane is clicked, the pane would open and show the rest of the results.
The problems I've had are that the repeater is not accessible from the code behind if it is inside the accordion. But I'm sure I wasn't doing it right anyways. I'm just trying to have an accordion that has as many panes as there are results from a datasource. If there is something other than a repeater that you can suggest, or the correct way to incorporate the repeater in the accordion to do what I want, suggest whatever! I just need to format how the results display how I want, unlike a gridview (I used tables in my normal repeater, and that worked fine, I just need to get that repeater to work inside of the accordion).
(and I know this isn't the section to ask about the accordion, but what is the AccordionExtender? It's not in the toolbox, and I can't find much online. It won't be recognized by Visual Studio, so I don't know what to do. If I could get that, I feel like it could solve my problem, as I found a possible solution online) I don't need to post my code, as it's a simple repeater, and trying to integrate it within the accordion isn't working no matter which way I try since I can't DataBind() in the codebehind. And yes, I tried to FindControl within the accordion but it wouldn't find the repeater.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
I have an application that runs on a client's server built on a SQL Server 2005 database.We have now developed an ASP.NET v2 application which connects to this database. This web application will be hosted on an ISP's server but needs to access the SQL Server database on the client's server.
The client's server has a firewall and so forth so I assume it should be possible to make the SQL Server accessible via the Internet but of course I am woriied about security. Can someone point me to some best practices to achieve this.
I'm getting this error when trying to connect to SqlServer:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
A few points:All was working well 6 hrs before, and I didn't change anything.I get the error anytime I try to connect to a local database (not remote, but I tried anyway to allow remote connections and here's a screenshot of what I get - there's nothing there:
http://www.zumodrive.com/share/5OKBNDg0OT)Screenshot of trying to configure SqlDataSource control: http://www.zumodrive.com/share/5OJEYmVhMm Screenshot of trying to connect in Sql Server Management Studio: http://www.zumodrive.com/share/5OJINGQ2MG
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
If i've the button outside an update panel (basically i'm using RadAjaxPanel by Telerik) it is working fine. But when the button is inside an ajax panel, even if i click OK for deleting the records the server side code is not called.
I have several checkbox controls on my web form that are not server controls (runat="server") How can I access these controls form my C# code? Can this be done with document.GetelementById from the server side using C#? Or some other technique?
I am not allowed to make these server controls (runat=server) because of a requirement.
Im dynamically creating several dropdowns onclick of a button... but the dropdown returns null when im trying to get the values on submitting the form... i read tat during postback all dynamically created controls will be lost... s there a way to register the controls... i want to access the item selected in the dropdown .... expecting a positive reply...
Setting value in html control in code behind without making server control
<input type="text" name="txt" /> <%--Pleas note I don't want put runat=server here to get the control in code behind--%> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
Code behind
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //If I want to initlize some value in input, how can I set here } } protected void Button1_Click(object sender, EventArgs e) { Request["txt"] // Here I am getting the value of input }
<form id="form1" runat="server" method="post" action="Default.aspx?id=<%= ID %>" >
Ok, it is very ugly and I wouldn't have ever tried it myself. It came up in some code that was written years ago but had been working up until this weekend after a bunch of updates were installed on a client's web server where the code is hosted.
The actual result of this is the following html:
<form name="form1" method="post" action="Default.aspx?id=<%= ID %>" id="form1">
The url ends up like this:
http://localhost:6735/Default.aspx?id=<%= ID %>
Which as you can see, demonstrates that the "<" symbol is being encoded before ASP.NET actually processes the page. It seems strange to me as I thought that even though it is not pretty by any means, it should work. I'm confused.
To make matters worse, the client insists that it is a bug in IE since it appears to work in Firefox. In fact, it is broken in Firefox as well, except for some reason Firefox treats it as a 0.
Any ideas on why this happens and how to fix it easily? Everything I try to render within the server control ends up getting escaped.
But that requires me to call DataBind which is adding more of a hack to the original hack. Guess if nobody thinks of anything else I'll have to go with that.
How to store aspx code or c# code or any server control code in database?is this possible or not?i am trying to give Aspx code in textbox and click save button comes an error...
I have to use inline code for an aspx page and I need to use a custom server control that is defined in the same aspx page but the control does not get processed as a server control. it gets returned as is as static html tag.
I am using following server side code to save the data from ASP.NET Control toolkit Editor to the database It follows with the HTML Code The problem is that, data is saved successfully. But it is saved twice. Main problem is this server side event is fired twice. How can i prevent it from firing twice?
Server side code Imports System.Data.SqlClient Partial Class Administrator_Calendar Inherits System.Web.UI.Page Protected Sub BtnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnAdd.Click Try Dim dbobj As New db Dim i As Integer = 0 Dim rdr As SqlDataReader = dbobj.selectQuery("select max(srno) from calendar") If rdr.HasRows = True Then rdr.Read() i = rdr.Item(0) End If rdr.Close() dbobj.insertQuery("insert into calendar values (" & i + 1 & " , '" & Me.Txt_dt.Text & "' , '" & Me.Editor1.Content & "')") dbobj = Nothing Catch ex As Exception End Try End Sub End Class HTML CODE <%@ Page Language="VB" MasterPageFile="~/MasterPages/Admin_AftrLogin.master" AutoEventWireup="false" CodeFile="Calendar.aspx.vb" Inherits="Administrator_Calendar" Title="Excel Crop Care Ltd. / Administration Section / Manage Calendar..." %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="cc2" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server"> <div> <cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0"> <cc1:TabPanel runat="server" HeaderText="Selected Dates" ID="TabPanel1"> <ContentTemplate> <asp:GridView ID="Gridview1" runat="server" AutoGenerateColumns="False" DataKeyNames="srno" DataSourceID="SqlDataSource1"> <Columns> <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True"> <ItemStyle Width="20%" /> </asp:CommandField> <asp:BoundField DataField="srno" HeaderText="No." ReadOnly="True" SortExpression="srno"> <ItemStyle Width="10%" /> </asp:BoundField> <asp:BoundField DataField="date" HeaderText="Date" SortExpression="date"> <ItemStyle Width="30%" /> </asp:BoundField> <asp:BoundField DataField="description" HeaderText="Description" SortExpression="description" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DataConnectionString %>" SelectCommand="SELECT * FROM [calendar]" UpdateCommand="Update calendar set date=@date,description=@description where srno=@srno" DeleteCommand="Delete from calendar where srno=@srno"></asp:SqlDataSource> </ContentTemplate> </cc1:TabPanel> <cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="Add New"> <ContentTemplate> <table> <tr> <td width="30%"> Date : </td> <td> <asp:TextBox ID="Txt_dt" runat="server" Height="16px" Width="170px" CausesValidation="True" Font-Names="Verdana" ForeColor="#666666"></asp:TextBox> <asp:ImageButton runat="Server" ID="Image1" ImageUrl="../Images/Calendar_scheduleHS.png" AlternateText="Click to show calendar" /><br /> <cc1:CalendarExtender ID="Txt_dt_CalendarExtender" runat="server" DaysModeTitleFormat="dd/MM/yy" Enabled="True" Format="dd/MM/yy" TargetControlID="Txt_dt" PopupButtonID="Image1"> </cc1:CalendarExtender> <cc1:TextBoxWatermarkExtender ID="Txt_dt_TextBoxWatermarkExtender" runat="server" Enabled="True" TargetControlID="Txt_dt" WatermarkText="DD/MM/YY"> </cc1:TextBoxWatermarkExtender> <cc1:MaskedEditExtender ID="Txt_dt_MaskedEditExtender" runat="server" MaskType="Date" CultureDateFormat="dd/MM/yy" Enabled="True" TargetControlID="Txt_dt" Century="2000" UserDateFormat="DayMonthYear" Mask="99/99/99"> </cc1:MaskedEditExtender> </td> </tr> <tr> <td colspan="2"> <asp:Label ID="Lbl_msg" runat="server" Text="Enter description in the editor below :"></asp:Label> </td> </tr> <tr> <td colspan="2"> <cc2:Editor ID="Editor1" runat="server" Height="350px" /> </td> </tr> <tr> <td colspan="2" align="center"> <asp:Button ID="BtnAdd" runat="server" Text="Add" OnClick="BtnAdd_Click" Width="75px" CssClass="btn" /> <asp:Button ID="Btn_Rem" runat="server" Text="Remove" OnClick="BtnAdd_Click" Width="75px" CssClass="btn" /> </td> </tr> </table> </ContentTemplate> </cc1:TabPanel> </cc1:TabContainer> </div> </asp:Content>
I'm trying to take an existing bunch of code that was previously on a full .aspx page, and do the same stuff in a .ashx handler.
The code created an HtmlTable object, added rows and cells to those rows, then added that html table the .aspx's controls collection, then added it to a div that was already on the page.
I am trying to keep the code in tact but instead of putting the control into a div, actually generate the html and I'll return that in a big chunk of text that can be called via AJAX client-side.
HtmlTable errors out when I try to use the InnerHtml property (says it isn't supported), and when I try RenderControl, after making first a TextWriter and next an HtmlTextWriter object, I get the error that Page cannot be null.
I'm new to custom server controls and I'm hoping to use them to build various 'modules' for different sites I build to cut down on duplicate code.I'm familiar with custom user controls in which I can create an .ascx & .ascx.vb file which can then be imported into an .aspx page and used freely.However, with custom server controls I cannot find a way of using markup/html code. Is this possible at all or must all code be created programmatically?