Search Results

Search found 1705 results on 69 pages for 'runat'.

Page 7/69 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Using WebParts results in blank page

    - by dale
    Hi, I'm developing an ASP.NET (C#) application using EPiServer CMS 5. On the startpage we have four WebPart-zones and everything works great running it through Visual Studio. When publishing it to the production-server the startpage shows as a blank page, no error what so ever... When we remove these lines of code it works, so it has something to do with the WebParts. <WebParts:ExtendedWebPartManager ID="WebPartsManager" runat="server"></WebParts:ExtendedWebPartManager> <WebParts:ExtendedWebPartZone WebPartProperty="WebPartZone1" runat="server" ID="WebPartZone1" PartChromeType="None" AllowLayoutChange="false" Padding="0" PartChromePadding="0" Width="100%"></WebParts:ExtendedWebPartZone> <WebParts:ExtendedWebPartZone WebPartProperty="WebPartZone2" runat="server" ID="WebPartZone2" PartChromeType="None" AllowLayoutChange="false" Padding="0" PartChromePadding="0" Width="100%"></WebParts:ExtendedWebPartZone> <WebParts:ExtendedWebPartZone WebPartProperty="WebPartZone3" runat="server" ID="WebPartZone3" PartChromeType="None" AllowLayoutChange="false" Padding="0" PartChromePadding="0" Width="100%"></WebParts:ExtendedWebPartZone> <WebParts:ExtendedWebPartZone WebPartProperty="WebPartZone4" runat="server" ID="WebPartZone4" PartChromeType="None" AllowLayoutChange="false" Padding="0" PartChromePadding="0" Width="100%"></WebParts:ExtendedWebPartZone>

    Read the article

  • Wiring up JavaScript handlers after a Partial Postback in ASP.NET

    - by Richard
    I am trying to use LinkButtons with the DefaultButton property of the ASP.NET Panel in an UpdatePanel. I have read and used the various other answers that are around describing the wiring up of the click event so that a full postback is not done instead of a partial postback. When the page loads, I wire up the .click function of the LinkButton so that the DefaultButton property of the ASP.NET panel will work. This all works fine, until you bring an UpdatePanel into the mix. With an UpdatePanel, if there is a partial postback, the script to wire up the .click function is not called in the partial postback, and hitting enter reverts to causing a full submit of the form rather than triggering the LinkButton. How can I cause javascript to be executed after a partial postback to re-wire up the .click function of the LinkButton? I have produced a sample page which shows the problem. There are two alerts showing 1) When the code to hook up the .click function is being called, and 2) When the .click function has been called (this only happens when you hit enter in the textbox after the event has been wired up). To test this code, type something in the textbox and hit Enter. The text will be copied to the label control, but "Wiring up Event Click" alert will not be shown. Add another letter, hit enter again, and you'll get a full postback without the text being copied to the label control (as the LinkButton wasn't called). Because that was a full postback, the Wiring Up Event Click event will be called again, and the form will work properly the next time again. This is being done with ASP.NET 3.5. Test Case Code: <%@ Page Language="C#" Inherits="System.Web.UI.Page" Theme="" EnableTheming="false" AutoEventWireup="true" %> <script runat="server"> void cmdComplete_Click(object sender, EventArgs e) { lblOutput.Text = "Complete Pressed: " + txtInput.Text; } void cmdFirstButton_Click(object sender, EventArgs e) { lblOutput.Text = "First Button Pressed"; } protected override void OnLoad(EventArgs e) { HookupButton(cmdComplete); } void HookupButton(LinkButton button) { // Use the click event of the LinkButton to trigger the postback (this is used by the .click code below) button.OnClientClick = Page.ClientScript.GetPostBackEventReference(button, String.Empty); // Wire up the .click event of the button to call the onclick function, and prevent a form submit string clickString = string.Format(@" alert('Wiring up click event'); document.getElementById('{0}').click = function() {{ alert('Default button pressed'); document.getElementById('{0}').onclick(); }};", button.ClientID, Page.ClientScript.GetPostBackEventReference(button, "")); Page.ClientScript.RegisterStartupScript(button.GetType(), "click_hookup_" + button.ClientID, clickString, true); } </script> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>DefaultButton/LinkButton Testing</title> <style type="text/css"> a.Button { line-height: 2em; padding: 5px; border: solid 1px #CCC; background-color: #EEE; } </style> </head> <body> <h1> DefaultButton/LinkButton Testing</h1> <form runat="server"> <asp:ScriptManager runat="server" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <div style="position: relative"> <fieldset> <legend>Output</legend> <asp:Label runat="server" ID="lblOutput" /> </fieldset> <asp:Button runat="server" Text="First Button" ID="cmdFirstButton" OnClick="cmdFirstButton_Click" UseSubmitBehavior="false" /> <asp:Panel ID="Panel1" runat="server" DefaultButton="cmdComplete"> <label> Enter Text:</label> <asp:TextBox runat="server" ID="txtInput" /> <asp:LinkButton runat="server" CssClass="Button" ID="cmdComplete" OnClick="cmdComplete_Click" Text="Complete" /> </asp:Panel> </div> </ContentTemplate> </asp:UpdatePanel> <asp:Button runat="server" ID="cmdFullPostback" Text="Full Postback" /> </form> </body> </html>

    Read the article

  • FAQ: Highlight GridView Row on Click and Retain Selected Row on Postback

    - by Vincent Maverick Durano
    A couple of months ago I’ve written a simple demo about “Highlighting GridView Row on MouseOver”. I’ve noticed many members in the forums (http://forums.asp.net) are asking how to highlight row in GridView and retain the selected row across postbacks. So I’ve decided to write this post to demonstrate how to implement it as reference to others who might need it. In this demo I going to use a combination of plain JavaScript and jQuery to do the client-side manipulation. I presumed that you already know how to bind the grid with data because I will not include the codes for populating the GridView here. For binding the gridview you can refer this post: Binding GridView with Data the ADO.Net way or this one: GridView Custom Paging with LINQ. To get started let’s implement the highlighting of GridView row on row click and retain the selected row on postback.  For simplicity I set up the page like this: <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>You have selected Row: (<asp:Label ID="Label1" runat="server" />)</h2> <asp:HiddenField ID="hfCurrentRowIndex" runat="server"></asp:HiddenField> <asp:HiddenField ID="hfParentContainer" runat="server"></asp:HiddenField> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Trigger Postback" /> <asp:GridView ID="grdCustomer" runat="server" AutoGenerateColumns="false" onrowdatabound="grdCustomer_RowDataBound"> <Columns> <asp:BoundField DataField="Company" HeaderText="Company" /> <asp:BoundField DataField="Name" HeaderText="Name" /> <asp:BoundField DataField="Title" HeaderText="Title" /> <asp:BoundField DataField="Address" HeaderText="Address" /> </Columns> </asp:GridView> </asp:Content>   Note: Since the action is done at the client-side, when we do a postback like (clicking on a button) the page will be re-created and you will lose the highlighted row. This is normal because the the server doesn't know anything about the client/browser not unless if you do something to notify the server that something has changed. To persist the settings we will use some HiddenFields control to store the data so that when it postback we can reference the value from there. Now here’s the JavaScript functions below: <asp:content id="Content1" runat="server" contentplaceholderid="HeadContent"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script> <script type="text/javascript">       var prevRowIndex;       function ChangeRowColor(row, rowIndex) {           var parent = document.getElementById(row);           var currentRowIndex = parseInt(rowIndex) + 1;                 if (prevRowIndex == currentRowIndex) {               return;           }           else if (prevRowIndex != null) {               parent.rows[prevRowIndex].style.backgroundColor = "#FFFFFF";           }                 parent.rows[currentRowIndex].style.backgroundColor = "#FFFFD6";                 prevRowIndex = currentRowIndex;                 $('#<%= Label1.ClientID %>').text(currentRowIndex);                 $('#<%= hfParentContainer.ClientID %>').val(row);           $('#<%= hfCurrentRowIndex.ClientID %>').val(rowIndex);       }             $(function () {           RetainSelectedRow();       });             function RetainSelectedRow() {           var parent = $('#<%= hfParentContainer.ClientID %>').val();           var currentIndex = $('#<%= hfCurrentRowIndex.ClientID %>').val();           if (parent != null) {               ChangeRowColor(parent, currentIndex);           }       }          </script> </asp:content>   The ChangeRowColor() is the function that sets the background color of the selected row. It is also where we set the previous row and rowIndex values in HiddenFields.  The $(function(){}); is a short-hand for the jQuery document.ready event. This event will be fired once the page is posted back to the server that’s why we call the function RetainSelectedRow(). The RetainSelectedRow() function is where we referenced the current selected values stored from the HiddenFields and pass these values to the ChangeRowColor() function to retain the highlighted row. Finally, here’s the code behind part: protected void grdCustomer_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onclick", string.Format("ChangeRowColor('{0}','{1}');", e.Row.ClientID, e.Row.RowIndex)); } } The code above is responsible for attaching the javascript onclick event for each row and call the ChangeRowColor() function and passing the e.Row.ClientID and e.Row.RowIndex to the function. Here’s the sample output below:   That’s it! I hope someone find this post useful! Technorati Tags: jQuery,GridView,JavaScript,TipTricks

    Read the article

  • Click edit button twice in gridview asp.net c# issue

    - by Supriyo Banerjee
    I have a gridview created on a page where I want to provide an edit button for the user to click in. However the issue is the grid view row becomes editable only while clicking the edit button second time. Not sure what is going wrong here, any help would be appreciated. One additional point is my grid view is displayed on the page only on a click of a button and is not there on page_load event hence. Posting the code snippets: //MY Aspx code <Columns> <asp:TemplateField HeaderText="Slice" SortExpression="name"> <ItemTemplate> <asp:Label ID="lblslice" Text='<%# Eval("slice") %>' runat="server"></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:Label ID="lblslice" Text='<%# Eval("slice") %>' runat="server"></asp:Label> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Metric" SortExpression="Description"> <ItemTemplate> <asp:Label ID="lblmetric" Text='<%# Eval("metric")%>' runat="server"></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:Label ID="lblmetric" Text='<%# Eval("metric")%>' runat="server"></asp:Label> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Original" SortExpression="Type"> <ItemTemplate> <asp:Label ID="lbloriginal" Text='<%# Eval("Original")%>' runat="server"></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:Label ID="lbloriginal" Text='<%# Eval("Original")%>' runat="server"></asp:Label> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="WOW" SortExpression="Market"> <ItemTemplate> <asp:Label ID="lblwow" Text='<%# Eval("WOW")%>' runat="server"></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:Label ID="lblwow" Text='<%# Eval("WOW")%>' runat="server"></asp:Label> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Change" SortExpression="Market" > <ItemTemplate> <asp:Label ID="lblChange" Text='<%# Eval("Change")%>' runat="server"></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="TxtCustomerID" Text='<%# Eval("Change") %> ' runat="server"></asp:TextBox> </EditItemTemplate> </asp:TemplateField> <asp:CommandField HeaderText="Edit" ShowEditButton="True" /> </Columns> </asp:GridView> //My code behind: protected void Page_Load(object sender, EventArgs e) { } public void populagridview1(string slice,string fromdate,string todate,string year) { SqlCommand cmd; SqlDataAdapter da; DataSet ds; cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_geteventchanges"; cmd.Connection = conn; conn.Open(); SqlParameter param1 = new SqlParameter("@slice", slice); cmd.Parameters.Add(param1); SqlParameter param2 = new SqlParameter("@fromdate", fromdate); cmd.Parameters.Add(param2); SqlParameter param3 = new SqlParameter("@todate", todate); cmd.Parameters.Add(param3); SqlParameter param4 = new SqlParameter("@year", year); cmd.Parameters.Add(param4); da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds, "Table"); GridView1.DataSource = ds; GridView1.DataBind(); conn.Close(); } protected void ImpactCalc(object sender, EventArgs e) { populagridview1(ddl_slice.SelectedValue, dt_to_integer(Picker1.Text), dt_to_integer(Picker2.Text), Txt_Year.Text); } protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { gvEditIndex = e.NewEditIndex; Gridview1.DataBind(); } My page layout This edit screen appears after clicking edit twice.. the grid view gets displayed on hitting the Calculate impact button. The data is from a backend stored procedure which is fired on clicking the Calculate impact button

    Read the article

  • BlogEngine - Mangling of HTML Anchor Links in TinyMCE Editor

    - by IrishChieftain
    When I create the following link: <a href="~/Contact.aspx" runat="server">Contact us</a> The editor strips out the runat attribute, breaking the link. It's also inserting "/page" into the URL which I do not want to happen. Is there some editor setting to prevent this from happening? I've checked here and couldn't find an answer. UPDATE I've added the following to tinyMCE.acsx to allow the addition of the runat attribute to anchor links: tinyMCE.init({ ... extended_valid_elements : "a[href|runat=server]" ... }); This solves the problem with the runat attribute being stripped out. My only remaining problem is the automatic insertion of "page" in the URL. Anybody?

    Read the article

  • FAQ&ndash;Highlight GridView Row on Click and Retain Selected Row on Postback

    - by Vincent Maverick Durano
    A couple of months ago I’ve written a simple demo about “Highlighting GridView Row on MouseOver”. I’ve noticed many members in the forums (http://forums.asp.net) are asking how to highlight row in GridView and retain the selected row across postbacks. So I’ve decided to write this post to demonstrate how to implement it as reference to others who might need it. In this demo I going to use a combination of plain JavaScript and jQuery to do the client-side manipulation. I presumed that you already know how to bind the grid with data because I will not include the codes for populating the GridView here. For binding the gridview you can refer this post: Binding GridView with Data the ADO.Net way or this one: GridView Custom Paging with LINQ. To get started let’s implement the highlighting of GridView row on row click and retain the selected row on postback.  For simplicity I set up the page like this: <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>You have selected Row: (<asp:Label ID="Label1" runat="server" />)</h2> <asp:HiddenField ID="hfCurrentRowIndex" runat="server"></asp:HiddenField> <asp:HiddenField ID="hfParentContainer" runat="server"></asp:HiddenField> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Trigger Postback" /> <asp:GridView ID="grdCustomer" runat="server" AutoGenerateColumns="false" onrowdatabound="grdCustomer_RowDataBound"> <Columns> <asp:BoundField DataField="Company" HeaderText="Company" /> <asp:BoundField DataField="Name" HeaderText="Name" /> <asp:BoundField DataField="Title" HeaderText="Title" /> <asp:BoundField DataField="Address" HeaderText="Address" /> </Columns> </asp:GridView> </asp:Content>   Note: Since the action is done at the client-side, when we do a postback like (clicking on a button) the page will be re-created and you will lose the highlighted row. This is normal because the the server doesn't know anything about the client/browser not unless if you do something to notify the server that something has changed. To persist the settings we will use some HiddenFields control to store the data so that when it postback we can reference the value from there. Now here’s the JavaScript functions below: <asp:content id="Content1" runat="server" contentplaceholderid="HeadContent"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script> <script type="text/javascript">       var prevRowIndex;       function ChangeRowColor(row, rowIndex) {           var parent = document.getElementById(row);           var currentRowIndex = parseInt(rowIndex) + 1;                 if (prevRowIndex == currentRowIndex) {               return;           }           else if (prevRowIndex != null) {               parent.rows[prevRowIndex].style.backgroundColor = "#FFFFFF";           }                 parent.rows[currentRowIndex].style.backgroundColor = "#FFFFD6";                 prevRowIndex = currentRowIndex;                 $('#<%= Label1.ClientID %>').text(currentRowIndex);                 $('#<%= hfParentContainer.ClientID %>').val(row);           $('#<%= hfCurrentRowIndex.ClientID %>').val(rowIndex);       }             $(function () {           RetainSelectedRow();       });             function RetainSelectedRow() {           var parent = $('#<%= hfParentContainer.ClientID %>').val();           var currentIndex = $('#<%= hfCurrentRowIndex.ClientID %>').val();           if (parent != null) {               ChangeRowColor(parent, currentIndex);           }       }          </script> </asp:content>   The ChangeRowColor() is the function that sets the background color of the selected row. It is also where we set the previous row and rowIndex values in HiddenFields.  The $(function(){}); is a short-hand for the jQuery document.ready function. This function will be fired once the page is posted back to the server that’s why we call the function RetainSelectedRow(). The RetainSelectedRow() function is where we referenced the current selected values stored from the HiddenFields and pass these values to the ChangeRowColor) function to retain the highlighted row. Finally, here’s the code behind part: protected void grdCustomer_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onclick", string.Format("ChangeRowColor('{0}','{1}');", e.Row.ClientID, e.Row.RowIndex)); } } The code above is responsible for attaching the javascript onclick event for each row and call the ChangeRowColor() function and passing the e.Row.ClientID and e.Row.RowIndex to the function. Here’s the sample output below:   That’s it! I hope someone find this post useful! Technorati Tags: jQuery,GridView,JavaScript,TipTricks

    Read the article

  • asp.net grid view hyper link pass values to new window

    - by srihari
    hai guys here is my question please help me I have a gridview with hyperlink fields here my requirement is if I click on hyperlink of particular row I need to display that particular row values into other page in that page user will edit record values after that if he clicks on update button I need to update that record values and get back to previous home page. if iam clicking hyper link in first window new window should open with out any url tool bar and minimize close buttons like popup modular Ajax ModalPopUpExtender but iam un able to ge that that one please help me the fillowing code is defalut.aspx <head runat="server"> <title>PassGridviewRow values </title> <style type="text/css"> #gvrecords tr.rowHover:hover { background-color:Yellow; font-family:Arial; } </style> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView runat="server" ID="gvrecords" AutoGenerateColumns="false" HeaderStyle-BackColor="#7779AF" HeaderStyle-ForeColor="White" DataKeyNames="UserId" RowStyle-CssClass="rowHover"> <Columns> <asp:TemplateField HeaderText="Change Password" > <ItemTemplate> <a href ='<%#"UpdateGridviewvalues.aspx?UserId="+DataBinder.Eval(Container.DataItem,"UserId") %>'> <%#Eval("UserName") %> </a> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="FirstName" HeaderText="FirstName" /> <asp:BoundField DataField="LastName" HeaderText="LastName" /> <asp:BoundField DataField="Email" HeaderText="Email" /> </Columns> </asp:GridView> </div> </form> </body> </html> following code default.aspx.cs code using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindGridview(); } } protected void BindGridview() { SqlConnection con = new SqlConnection("Data Source=.;Integrated Security=SSPI;Initial Catalog=testdb1"); con.Open(); SqlCommand cmd = new SqlCommand("select * from UserDetails", con); SqlDataAdapter da = new SqlDataAdapter(cmd); cmd.ExecuteNonQuery(); con.Close(); DataSet ds = new DataSet(); da.Fill(ds); gvrecords.DataSource = ds; gvrecords.DataBind(); } } this is updategridviewvalues.aspx <head runat="server"> <title>Update Gridview Row Values</title> <script type="text/javascript"> function Showalert(username) { alert(username + ' details updated successfully.'); if (alert) { window.location = 'Default.aspx'; } } </script> </head> <body> <form id="form1" runat="server"> <div> <table> <tr> <td colspan="2" align="center"> <b> Edit User Details</b> </td> </tr> <tr> <td> User Name: </td> <td> <asp:Label ID="lblUsername" runat="server"/> </td> </tr> <tr> <td> First Name: </td> <td> <asp:TextBox ID="txtfname" runat="server"></asp:TextBox> </td> </tr> <tr> <td> Last Name: </td> <td> <asp:TextBox ID="txtlname" runat="server"></asp:TextBox> </td> </tr> <tr> <td> Email: </td> <td> <asp:TextBox ID="txtemail" runat="server"></asp:TextBox> </td> </tr> <tr> <td> </td> <td> <asp:Button ID="btnUpdate" runat="server" Text="Update" onclick="btnUpdate_Click" /> <asp:Button ID="btnCancel" runat="server" Text="Cancel" onclick="btnCancel_Click"/> </td> </tr> </table> </div> </form> </body> </html> and my updategridviewvalues.aspx.cs code is follows using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class UpdateGridviewvalues : System.Web.UI.Page { SqlConnection con = new SqlConnection("Data Source=.;Integrated Security=SSPI;Initial Catalog=testdb1"); private int userid=0; protected void Page_Load(object sender, EventArgs e) { userid = Convert.ToInt32(Request.QueryString["UserId"].ToString()); if(!IsPostBack) { BindControlvalues(); } } private void BindControlvalues() { con.Open(); SqlCommand cmd = new SqlCommand("select * from UserDetails where UserId=" + userid, con); SqlDataAdapter da = new SqlDataAdapter(cmd); cmd.ExecuteNonQuery(); con.Close(); DataSet ds = new DataSet(); da.Fill(ds); lblUsername.Text = ds.Tables[0].Rows[0][1].ToString(); txtfname.Text = ds.Tables[0].Rows[0][2].ToString(); txtlname.Text = ds.Tables[0].Rows[0][3].ToString(); txtemail.Text = ds.Tables[0].Rows[0][4].ToString(); } protected void btnUpdate_Click(object sender, EventArgs e) { con.Open(); SqlCommand cmd = new SqlCommand("update UserDetails set FirstName='" + txtfname.Text + "',LastName='" + txtlname.Text + "',Email='" + txtemail.Text + "' where UserId=" + userid, con); SqlDataAdapter da = new SqlDataAdapter(cmd); int result= cmd.ExecuteNonQuery(); con.Close(); if(result==1) { ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowSuccess", "javascript:Showalert('"+lblUsername.Text+"')", true); } } protected void btnCancel_Click(object sender, EventArgs e) { Response.Redirect("~/Default.aspx"); } } My requirement is new window should come like pop window as new window with out having url and close button my database tables is ColumnName DataType ------------------------------------------- UserId Int(set identity property=true) UserName varchar(50) FirstName varchar(50) LastName varchar(50) Email Varchar(50)

    Read the article

  • How to display table in ASP.NET website?

    - by salvationishere
    I am developing a C# VS 2008 / SQL Server 2008 website, but now I cannot display the Gridview containing my table. I included the Default.aspx and aspx.cs files below. What do I need to do to fix this? I am not getting any errors now; just that this grid does not show up. Thanks! ASPX file: <%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server"> <asp:Panel runat="server" ID="AuthenticatedMessagePanel"> <asp:Label runat="server" ID="WelcomeBackMessage"></asp:Label> <table> <tr > <td> <asp:Label ID="tableLabel" runat="server" Font-Bold="True" Text="Select target table:"></asp:Label> </td> <td> <asp:Label ID="inputLabel" runat="server" Font-Bold="True" Text="Select input file:"></asp:Label> </td></tr> <tr><td valign="top"> <asp:Label ID="feedbackLabel" runat="server"></asp:Label> <asp:SqlDataSource ID="SelectTables" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorks3_SelectTables %>" SelectCommand="SELECT TABLE_NAME FROM information_schema.Tables WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = @SchemaName"> <SelectParameters> <asp:Parameter Name="SchemaName" Type="String" DefaultValue="" /> </SelectParameters> <InsertParameters> <asp:Parameter Name="TABLE_NAME" Direction="Output" Type="String" DefaultValue="" /> </InsertParameters> </asp:SqlDataSource> <asp:GridView ID="GridView1" DatasourceID="SelectTables" runat="server" style="WIDTH: 400px;" CellPadding="4" ForeColor="#333333" GridLines="None" onselectedindexchanged="GridView1_SelectedIndexChanged" AutoGenerateSelectButton="True" DataKeyNames="TABLE_NAME"> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <Columns> <asp:BoundField HeaderText="TABLE_NAME" DataField="TABLE_NAME" /> </Columns> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#999999" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:GridView> </td> <td valign="top"> <input id="uploadFile" type="file" size="26" runat="server" name="uploadFile" title="UploadFile" class="greybar" enableviewstate="True" /> </td></tr> </table> </asp:Panel> <asp:Panel runat="Server" ID="AnonymousMessagePanel"> <asp:HyperLink runat="server" ID="lnkLogin" Text="Log In" NavigateUrl="~/Login.aspx"> </asp:HyperLink> </asp:Panel> </asp:Content> ASPX.CS file: using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Collections.Generic; using System.IO; using System.Drawing; using System.ComponentModel; using System.Data.SqlClient; using ADONET_namespace; using System.Security.Principal; //using System.Windows; public partial class _Default : System.Web.UI.Page //namespace AddFileToSQL { //protected System.Web.UI.HtmlControls.HtmlInputFile uploadFile; protected System.Web.UI.HtmlControls.HtmlInputButton btnOWrite; protected System.Web.UI.HtmlControls.HtmlInputButton btnAppend; protected System.Web.UI.WebControls.Label Label1; protected static string inputfile = ""; public static string targettable; public static string selection; // Number of controls added to view state protected int default_NumberOfControls { get { if (ViewState["default_NumberOfControls"] != null) { return (int)ViewState["default_NumberOfControls"]; } else { return 0; } } set { ViewState["default_NumberOfControls"] = value; } } protected void uploadFile_onclick(object sender, EventArgs e) { } protected void Load_GridData() { //GridView1.DataSource = ADONET_methods.DisplaySchemaTables(); //GridView1.DataBind(); } protected void btnOWrite_Click(object sender, EventArgs e) { if (uploadFile.PostedFile.ContentLength > 0) { feedbackLabel.Text = "You do not have sufficient access to overwrite table records."; } else { feedbackLabel.Text = "This file does not contain any data."; } } protected void btnAppend_Click(object sender, EventArgs e) { string fullpath = Page.Request.PhysicalApplicationPath; string path = uploadFile.PostedFile.FileName; if (File.Exists(path)) { // Create a file to write to. try { StreamReader sr = new StreamReader(path); string s = ""; while (sr.Peek() > 0) s = sr.ReadLine(); sr.Close(); } catch (IOException exc) { Console.WriteLine(exc.Message + "Cannot open file."); return; } } if (uploadFile.PostedFile.ContentLength > 0) { inputfile = System.IO.File.ReadAllText(path); Session["Message"] = inputfile; Response.Redirect("DataMatch.aspx"); } else { feedbackLabel.Text = "This file does not contain any data."; } } protected void Page_Load(object sender, EventArgs e) { if (Request.IsAuthenticated) { WelcomeBackMessage.Text = "Welcome back, " + User.Identity.Name + "!"; // Reference the CustomPrincipal / CustomIdentity CustomIdentity ident = User.Identity as CustomIdentity; if (ident != null) WelcomeBackMessage.Text += string.Format(" You are the {0} of {1}.", ident.Title, ident.CompanyName); AuthenticatedMessagePanel.Visible = true; AnonymousMessagePanel.Visible = false; if (!Page.IsPostBack) { Load_GridData(); } } else { AuthenticatedMessagePanel.Visible = false; AnonymousMessagePanel.Visible = true; } } protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow row = GridView1.SelectedRow; targettable = row.Cells[2].Text; } }

    Read the article

  • Find Label Control in Repeater Asp.net

    - by user2769165
    I am using repeater and I want to find the label control in my repeater. here is my code <asp:Repeater ID="friendRepeater" runat="server"> <table cellpadding="0" cellspacing="0"> <ItemTemplate> <tr style=" width:700px; height:120px;"> <td> <div style=" padding-left:180px;"> <div id="leftHandPost" style="float:left; width:120px; height:120px; border: medium solid #cdaf95; padding-top:5px;"> <div id="childLeft" style=" padding-left:5px;"> <div id="photo" style=" border: thin solid black; width:100px;height:100px;"> <asp:Image id="photoImage" runat="server" ImageUrl='<%# String.Concat("Images/", Eval("Picture")) %>' Width="100px" Height="100px" /> </div> </div><!--childLeft--> </div><!--leftHandPost--> </div> </td> <td> <div id="rightHandPost" style=" float:right; padding-right:260px;"> <div id="childRight" style="width:400px; height:120px; border: medium solid #cdaf95; padding-top:5px; padding-left:10px;"> <strong><asp:Label id="lblName" runat="server"><%# Eval("PersonName") %></asp:Label></strong><br /> <div style=" float:right; padding-right:10px;"><asp:Button runat="server" Text="Add" onClick="add" /></div><br /> <asp:Label id="lblID" runat="server"><%# Eval("PersonID") %></asp:Label><br /> <asp:Label id="lblEmail" runat="server"><%# Eval("Email") %></asp:Label> </div><!--childRight--> </div><!--rightHandPost--> </td> </tr> </ItemTemplate> <AlternatingItemTemplate> <tr style=" width:700px; height:120px;"> <td> <div style=" padding-left:180px;"> <div id="Div1" style="float:left; width:120px; height:120px; border: medium solid #cdaf95; padding-top:5px;"> <div id="Div2" style="padding-left:5px;"> <div id="Div3" style=" border: thin solid black; width:100px;height:100px;"> <asp:Image id="photoImage" runat="server" ImageUrl='<%# String.Concat("Images/", Eval("Picture")) %>' Width="100px" Height="100px" /> </div> </div><!--childLeft--> </div><!--leftHandPost--> </div> </td> <td> <div id="Div4" style=" float:right; padding-right:260px;"> <div id="Div5" style="width:400px; height:120px; border: medium solid #cdaf95; padding-top:5px; padding-left:10px;"> <strong><asp:Label id="lblName" runat="server"><%# Eval("PersonName")%></asp:Label></strong> <div style=" float:right; padding-right:10px;"><asp:Button id="btnAdd" runat="server" Text="Add" onClick="add"></asp:Button></div><br /> <br /> <asp:Label id="lblID" runat="server"><%# Eval("PersonID") %></asp:Label><br /> <asp:Label id="lblEmail" runat="server"><%# Eval("Email") %></asp:Label> </div><!--childRight--> </div><!--rightHandPost--> </td> </tr> </AlternatingItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater> Here is the code behind for the add button. protected void add(object sender, EventArgs e) { DateTime date = DateTime.Now; System.Web.UI.WebControls.Label la = (System.Web.UI.WebControls.Label)friendRepeater.FindControl("PersonID"); String id = la.Text; try { MySqlConnection connStr = new MySqlConnection(); connStr.ConnectionString = "Server = localhost; Database = healthlivin; Uid = root; Pwd = khei92;"; String insertFriend = "INSERT INTO contactFriend(friendID, PersonID, PersonIDB, date) values (@id, @personIDA, @personIDB, @date)"; MySqlCommand cmdInsertStaff = new MySqlCommand(insertFriend, connStr); cmdInsertStaff.Parameters.AddWithValue("@id", "F000004"); cmdInsertStaff.Parameters.AddWithValue("@personIDA", "M000001"); cmdInsertStaff.Parameters.AddWithValue("@personIDB", id); cmdInsertStaff.Parameters.AddWithValue("@date", date); connStr.Open(); cmdInsertStaff.ExecuteNonQuery(); MessageBox.Show("inserted"); connStr.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } I have get the error of Object reference not set to an instance of an object. I think is because there are no value in the Label. The Find Control are not working. May I know how can fix this problem? Thank you very much

    Read the article

  • Access Master Page Controls II

    - by Bunch
    Here is another way to access master page controls. This way has a bit less coding then my previous post on the subject. The scenario would be that you have a master page with a few navigation buttons at the top for users to navigate the app. After a button is clicked the corresponding aspx page would load in the ContentPlaceHolder. To make it easier for the users to see what page they are on I wanted the clicked navigation button to change color. This would be a quick visual for the user and is useful when inevitably they are interrupted with something else and cannot get back to what they were doing for a little while. Anyway the code is something like this. Master page: <body>     <form id="form1" runat="server">     <div id="header">     <asp:Panel ID="Panel1" runat="server" CssClass="panelHeader" Width="100%">        <center>            <label style="font-size: large; color: White;">Test Application</label>        </center>       <asp:Button ID="btnPage1" runat="server" Text="Page1" PostBackUrl="~/Page1.aspx" CssClass="navButton"/>       <asp:Button ID="btnPage2" runat="server" Text="Page2" PostBackUrl="~/Page2.aspx" CssClass="navButton"/>       <br />     </asp:Panel>     <br />     </div>     <div>         <asp:scriptmanager ID="Scriptmanager1" runat="server"></asp:scriptmanager>         <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">         </asp:ContentPlaceHolder>     </div>     </form> </body> Page 1: VB Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load     Dim clickedButton As Button = Master.FindControl("btnPage1")     clickedButton.CssClass = "navButtonClicked" End Sub CSharp protected void Page_Load(object sender, EventArgs e) {     Button clickedButton;     clickedButton = (Button)Master.FindControl("btnPage1");     clickedButton.CssClass = "navButtonClicked"; } CSS: .navButton {     background-color: White;     border: 1px #4e667d solid;     color: #2275a7;     display: inline;     line-height: 1.35em;     text-decoration: none;     white-space: nowrap;     width: 100px;     text-align: center;     margin-bottom: 10px;     margin-left: 5px;     height: 30px; } .navButtonClicked {     background-color:#FFFF86;     border: 1px #4e667d solid;     color: #2275a7;     display: inline;     line-height: 1.35em;     text-decoration: none;     white-space: nowrap;     width: 100px;     text-align: center;     margin-bottom: 10px;     margin-left: 5px;     height: 30px; } The idea is pretty simple, use FindControl for the master page in the page load of your aspx page. In the example I changed the CssClass for the aspx page's corresponding button to navButtonClicked which has a different background-color and makes the clicked button stand out. Technorati Tags: ASP.Net,CSS,CSharp,VB.Net

    Read the article

  • Using data input from pop-up page to current with partial refresh

    - by dpDesignz
    I'm building a product editor webpage using visual C#. I've got an image uploader popping up using fancybox, and I need to get the info from my fancybox once submitted to go back to the first page without clearing any info. I know I need to use ajax but how would I do it? <%@ Page Language="C#" AutoEventWireup="true" CodeFile="uploader.aspx.cs" Inherits="uploader" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> </head> <body style="width:350px; height:70px;"> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> <div style="width:312px; height:20px; background-color:Gray; color:White; padding-left:8px; margin-bottom:4px; text-transform:uppercase; font-weight:bold;">Uploader</div> <asp:FileUpload id="fileUp" runat="server" /> <asp:Button runat="server" id="UploadButton" text="Upload" onclick="UploadButton_Click" /> <br /><asp:Label ID="txtFile" runat="server"></asp:Label> <div style="width:312px; height:15px; background-color:#CCCCCC; color:#4d4d4d; padding-right:8px; margin-top:4px; text-align:right; font-size:x-small;">Click upload to insert your image into your product</div> </div> </form> </body> </html> CS so far using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Configuration; // Add to page using System.Web.UI; using System.Web.UI.WebControls; using System.Data; // Add to the page using System.Data.SqlClient; // Add to the page using System.Text; // Add to Page public partial class uploader : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void UploadButton_Click(object sender, EventArgs e) { if (fileUp.HasFile) try { fileUp.SaveAs("\\\\london\\users\\DP006\\Websites\\images\\" + fileUp.FileName); string imagePath = fileUp.PostedFile.FileName; } catch (Exception ex) { txtFile.Text = "ERROR: " + ex.Message.ToString(); } finally { } else { txtFile.Text = "You have not specified a file."; } } }

    Read the article

  • ASP.NET Update Panel with CheckBox - Not Working Properly

    - by rwponu
    I'm working on a simple demo project so that I can learn some things about ASP.NET's AJAX capabilities. My problem is that I can't seem to get an UpdatePanel to work properly with a CheckBox inside of it. Here is the markup I'm using in my .aspx file: <asp:ScriptManager ID="SM1" runat="server" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <tr> <td><asp:CheckBox ID="chkPaypal" runat="server" Text="Paypal" OnCheckedChanged="PayPal_CheckedChanged" AutoPostBack="true" /></td> </tr> <asp:Panel ID="pnlPayPal" runat="server" Visible="false"> <tr> <td>&nbsp;&nbsp;<asp:Label runat="server" ID="lblPaypalEmail" Text="Email:" /></td> <td><asp:TextBox runat="server" ID="tbPaypalEmail" Text="" Width="250px" /></td> </tr> <tr><td>&nbsp;</td></tr> </asp:Panel> </ContentTemplate> <Triggers> <asp:ASyncPostBackTrigger ControlID="chkPayPal" /> </Triggers> </asp:UpdatePanel> In my code behind, I'm simply saying: protected void PayPal_CheckedChanged(object sender, EventArgs e) { pnlPayPal.Visible = true; } Instead of making the panel visible as I anticipate, it is adding another "PayPal" checkbox at the top of the page. Any ideas?

    Read the article

  • Gridview and Modal popup not updating

    - by rs
    I have page with following controls <asp:UpdatePanel ID="up1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <uc2:CountryControl ID="Country1" runat="server" /> <br class = "br_e" /> <br class = "br_e" /> <asp:UpdatePanel ID="upCountry2" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Panel runat="server" ID="pnCountry" Width="400px" Visible="false"> <asp:GridView ID="gvCountry" runat="server" AllowSorting="true" DataKeyNames="countryid" DataSourceID="data_country1" AutoGenerateColumns="false"> <Columns> <asp:CommandField ButtonType="Link" ShowDeleteButton="true" /> <asp:BoundField HeaderText="Country" DataField="CountryName" SortExpression="CountryName" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="data_country1" runat="server" ConnectionString="<%$ zyx %>" SelectCommand="xyz" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:SessionParameter Name="country" DefaultValue="" ConvertEmptyStringToNull="true" SessionField="CountryID" Type="String" /> </SelectParameters> </asp:SqlDataSource> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> </ContentTemplate> </asp:UpdatePanel> My user control is a modal popup to select country and add selected ids to a session variable. And in main page bind data using ids in session variable.Gridview - on deleting event i'm deleting that id from session and on deleted event updating both user control using a refresh method (Country1.Refresh()) and gridview panel. But updatepanel is not getting updated and even modalpopup is also not getting refreshed. What could be wrong here? Even though update and refresh events are fired and executed, why is page not getting updated?

    Read the article

  • asp.net updatepanel inside hidden panel possible bug

    - by MakkyNZ
    Hi The javascript generated by the asp.net SciptManager control seems to have a bug and cant handle hidden UpdatePanels. A javascript error is thrown when a control within one updated panel tries to make another update panel visible. Is this a bug with ASP.Net ajax? And does anyone have any ideas how to get around this? heres is an example of when im trying to to <script type="text/C#" runat="server"> protected void LinkButton1_Click(object sender, EventArgs e) { Panel1.Visible = true; } </script> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" Text="Show Panel"></asp:LinkButton> </ContentTemplate> </asp:UpdatePanel> <asp:Panel ID="Panel1" runat="server" Visible="false"> <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> blah bla blah </ContentTemplate> </asp:UpdatePanel> </asp:Panel> this is the javascript error that gets thrown when clicking on the "LinkButton1" link. This error comes from the javascript that is generated by the asp.net ScriptManager control Error: Sys.InvalidOperationException: Could not find UpdatePanel with ID 'ctl00_ContentPlaceHolder1_UpdatePanel2'

    Read the article

  • ASP.NET UpdatePanel > Get selected value from checbox list outside of panel

    - by Rob
    Hi, I have a listing in an UpdatePanel I have some filters for that list in the form a checkboxList control. The checkboxList is created dynamically on page load During the Ajax update (postback), the checkbox list is not populated form the viewstate, so I cannot get the listing to filter. Note: If I put the checkbox list items directly in the markup, it all works, just not if the listing is populated on-postback. protected override void OnLoad(EventArgs e) { if (!Page.IsPostBack) { foreach (var p in global.Product) CheckListManufacurer.Items.Add(new ListItem(p, p)); } base.OnLoad(e); } <form id="ProductListForm" runat="server"> <asp:ScriptManager ID="ScriptManager" runat="server" EnablePartialRendering="true"></asp:ScriptManager> <asp:CheckBoxList ID="CheckListManufacurer" runat="server" EnableViewState="true"> <asp:ListItem Value="" Text="(All)"></asp:ListItem> </asp:CheckBoxList> <asp:Button id="btnTestAjax" runat="server" Text="Test" /> <asp:UpdatePanel ID="ProductsPanel" runat="server" UpdateMode="Conditional"> <Triggers> <asp:AsyncPostBackTrigger ControlID="btnTestAjax" /> <asp:AsyncPostBackTrigger ControlID="CheckListManufacurer" /> </Triggers> <ContentTemplate> <sr:ProductList ID="Products" runat="server" /> </ContentTemplate> </asp:UpdatePanel> </form>

    Read the article

  • Update panel problem

    - by ram
    Here is my code: <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" ChildrenAsTriggers="false" runat="server"> <ContentTemplate> <asp:Button ID="Button1" runat="server" Text="Click1" OnClick="Button1_Click" /> <br /> <br /> Last refresh <%=DateTime.Now.ToString() %> <br /> <br /> <asp:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional" ChildrenAsTriggers="true" runat="server"> <ContentTemplate> <asp:Button ID="Button2" runat="server" Text="Click2" OnClick="Button2_Click" /> <br /> <br /> Last refresh <%=DateTime.Now.ToString() %> <br /> <br /> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" /> </Triggers> </asp:UpdatePanel> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" /> </Triggers> </asp:UpdatePanel> </div> </form> </body> Im using two update panels here, when i click "Button2" then "UpdatePanel2" was refreshed, if i click "Button1" then both update panel were refreshed, but my need is if i click "Button1" then "UpdatePanel1" have to be refreshed. Thanks.

    Read the article

  • Loosing Textbox value on postback

    - by Dusty Roberts
    Hi Peeps i have an href that once clicking on it, it opens a dialog and sets a textbox value for that dialog. however, once i click on submit in that dialog, the textbox value is null. Link: <a href="#" onclick="javascript:expand('https://me.yahoo.com'); jQuery('#openiddialog').dialog('open'); return false;"><img id="yahoo" class="spacehw" src="/Content/Images/spacer.gif" /></a> Script: <script type="text/javascript"> jQuery(document).ready(function () { jQuery("#openiddialog").dialog({ autoOpen: false, width: 600, modal: true, buttons: { "Cancel": function () { $(this).dialog("close"); } } }); }); function expand(obj) { $("#<%=openIdBox.ClientID %>").val(obj); } </script> Dialog:<div id="openiddialog" title="Log in using OpenID"> <p> <asp:Label ID="Label1" runat="server" Text="OpenID Login" /> <asp:TextBox ID="openIdBox" EnableViewState="true" runat="server" /> <asp:JButton Icon="ui-icon-key" ID="loginButton" runat="server" Text="Authenticate" OnClick="loginButton_Click" /> <asp:CustomValidator runat="server" ID="openidValidator" ErrorMessage="Invalid OpenID Identifier" ControlToValidate="openIdBox" EnableViewState="false" OnServerValidate="openidValidator_ServerValidate" /> <br /> <asp:Label ID="loginFailedLabel" runat="server" EnableViewState="False" Text="Login failed" Visible="False" /> <asp:Label ID="loginCanceledLabel" runat="server" EnableViewState="False" Text="Login canceled" Visible="False" /> </p> </div> ... sorry... can't fix formatting ?!?

    Read the article

  • C# set custom UserControl variables when its in a Repeater

    - by tnriverfish
    <%@ Register Src="~/Controls/PressFileDownload.ascx" TagName="pfd" TagPrefix="uc1" %> <asp:Repeater id="Repeater1" runat="Server" OnItemDataBound="RPTLayer_OnItemDataBound"> <ItemTemplate> <asp:Label ID="LBLHeader" Runat="server" Visible="false"></asp:Label> <asp:Image ID="IMGThumb" Runat="server" Visible="false"></asp:Image> <asp:Label ID="LBLBody" Runat="server" class="layerBody"></asp:Label> <uc1:pfd ID="pfd1" runat="server" ShowContainerName="false" ParentContentTypeId="55" /> <asp:Literal ID="litLayerLinks" runat="server"></asp:Literal> </ItemTemplate> </asp:Repeater> System.Web.UI.WebControls.Label lbl; System.Web.UI.WebControls.Literal lit; System.Web.UI.WebControls.Image img; System.Web.UI.WebControls.HyperLink hl; System.Web.UI.UserControl uc; I need to set the ParentItemID variable for the uc1:pdf listed inside the repeater. I thought I should be able to find uc by looking in the e.Item and then setting it somehow. I think this is the part where I'm missing something. uc = (UserControl)e.Item.FindControl("pfd1"); if (uc != null) { uc.Attributes["ParentItemID"] = i.ItemID.ToString(); } Any thoughts would be appreciated.

    Read the article

  • ASP.NET dropdownlist callback doesn't work inside div

    - by Wayne Werner
    This seems super weird to me. I have a callback handler done in VB which works fine with this code: <!-- Div Outside Form --> <div class="container"> <form id="querydata" runat="server"> <asp:DropDownList runat="server" ID="myddl" AutoPostBack="true" OnSelectedIndexChanged="myddlhandler"> <asp:ListItem>Hello</asp:ListItem> <asp:ListItem>Goodbye</asp:ListItem> </asp:DropDownList> <asp:Label runat="server" ID="label1"></asp:Label> </form> </div> <!-- Yep, they're matching --> I can change the value and everything is A-OK, but if I change the code to this (div inside form): <form id="querydata" runat="server"> <!-- Div inside form doesn't work :( --> <div class="container"> <asp:DropDownList runat="server" ID="myddl" AutoPostBack="true" OnSelectedIndexChanged="myddlhandler"> <asp:ListItem>Hello</asp:ListItem> <asp:ListItem>Goodbye</asp:ListItem> </asp:DropDownList> <asp:Label runat="server" ID="label1"></asp:Label> </div> </form> It the postback no longer works. Is how asp is supposed to work? Or is it some magic error that only works for me? And most importantly, if asp is not supposed to work this way, how should I be doing this? Thanks!

    Read the article

  • Set Custom ASP.NET UserControl variables when its in a Repeater

    - by tnriverfish
    <%@ Register Src="~/Controls/PressFileDownload.ascx" TagName="pfd" TagPrefix="uc1" %> <asp:Repeater id="Repeater1" runat="Server" OnItemDataBound="RPTLayer_OnItemDataBound"> <ItemTemplate> <asp:Label ID="LBLHeader" Runat="server" Visible="false"></asp:Label> <asp:Image ID="IMGThumb" Runat="server" Visible="false"></asp:Image> <asp:Label ID="LBLBody" Runat="server" class="layerBody"></asp:Label> <uc1:pfd ID="pfd1" runat="server" ShowContainerName="false" ParentContentTypeId="55" /> <asp:Literal ID="litLayerLinks" runat="server"></asp:Literal> </ItemTemplate> </asp:Repeater> System.Web.UI.WebControls.Label lbl; System.Web.UI.WebControls.Literal lit; System.Web.UI.WebControls.Image img; System.Web.UI.WebControls.HyperLink hl; System.Web.UI.UserControl uc; I need to set the ParentItemID variable for the uc1:pdf listed inside the repeater. I thought I should be able to find uc by looking in the e.Item and then setting it somehow. I think this is the part where I'm missing something. uc = (UserControl)e.Item.FindControl("pfd1"); if (uc != null) { uc.Attributes["ParentItemID"] = i.ItemID.ToString(); } Any thoughts would be appreciated. Also tried this with similar results... when I debug inside my usercontrol (pfd1) the parameters I am trying to set have not been set. uc = (UserControl)e.Item.FindControl("pfd1"); if (uc != null) { uc.Attributes.Add("ContainerID", _cid.ToString()); uc.Attributes.Add("ParentItemId", i.ItemID.ToString()); }

    Read the article

  • Stop Visual Studio from appending numbers to the end of new controls

    - by techturtle
    I am wondering if there is any way to stop Visual Studio 2010 from appending a number to the end of the ID on new controls I create. For example, when I add a new TextBox, I would prefer that it do this: <asp:TextBox ID="TextBox" runat="server"> <asp:TextBox ID="TextBox" runat="server"> <asp:TextBox ID="TextBox" runat="server"> Instead of this: <asp:TextBox ID="TextBox1" runat="server"> <asp:TextBox ID="TextBox2" runat="server"> <asp:TextBox ID="TextBox3" runat="server"> It would make it easier to rename them appropriately, so I don't have to arrow/mouse over and delete the number each time. As I was writing this, the "Questions that may already have your answer" suggested this: How do I prevent Visual Studio from renaming my controls? which admittedly was the biggest part of my annoyance, but that appears to turn off putting in an ID="" field altogether, not just for pasted controls. It would still be helpful to turn off the numbering for new, non-pasted controls and have it not rename pasted ones as well. At the moment I'm working with ASP.NET, but it would be nice if it there was a way to do it for WinForms as well. Before anyone suggests it, I do know that allowing it to append the numbers prevents name conflicts should I not rename them appropriately. However, I would much rather have it fail to compile so I know to fix the issue now (if I forget to name something properly) rather than find random "TextBox1" items lying around in the code later on.

    Read the article

  • AJAX UpdatePanel.Visible Property not working with Javascript

    - by Ahmet Altun
    I have code below. I want to hide the update panel by using Javascript (without going to server) when the user clicks Hide button. Although javascript funciton seems to be working fine in debugging, it does not hide! <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" % <script type="text/javascript" language="javascript"> function Show() { document.getElementById("UpdatePanel1").Visible = true; } function Hide() { document.getElementById("UpdatePanel1").Visible = false; } </script> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:Button ID="btnShow" runat="server" Text="Show" OnClientClick="Show(); return false;" /> <asp:Button ID="BtnHide" runat="server" Text="Hide" OnClientClick="Hide(); return false;" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <br /> <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"></asp:TextBox> <br /> <asp:Button ID="btnSubmit" runat="server" Text="Gönder" onclick="btnSubmit_Click" /> <br /> </ContentTemplate> </asp:UpdatePanel> </div> </form>

    Read the article

  • How can i pull an image and data from a Database?

    - by user1851377
    I am trying to pull data from a Database using C#.net and use a Foreach loop to make it visible on a page. Every time i run the code i only get one item that shows up when i know that there is at least 7 items in the DB. i have placed the code below for the C#. SqlConnection oConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["HomeGrownEnergyConnectionString"].ToString()); string sqlEnergy = "Select * from Product p where p.ProductTypeId=3"; SqlCommand oCmd = new SqlCommand(sqlEnergy, oConnection); DataTable dtenergy = new DataTable(); SqlDataAdapter oDa = new SqlDataAdapter(oCmd); try { oConnection.Open(); ; oDa.Fill(dtenergy); } catch (Exception ex) { lblnodata.Text = ex.Message; return; } finally { oConnection.Close(); } DataTableReader results = dtenergy.CreateDataReader(); if (results.HasRows) { results.Read(); foreach(DataRow result in dtenergy.Rows) { byte[] imgProd = result["ThumnailLocation"] as byte[]; ID.Text = result["ProductID"].ToString(); Name.Text = result["Name"].ToString(); price.Text = FormatPriceColumn(result["Price"].ToString()); } } Here is the code for the asp.net. <div> <asp:Image ID="imgProd" CssClass="ProdImg" runat="server" /> <asp:Label runat="server" ID="ID" /> <asp:Label runat="server" ID="Name" /> <asp:Label runat="server" ID="price" /> <asp:TextBox ID="txtQty" MaxLength="3" runat="server" Width="30px" /> <asp:Button runat="server" ID="Addtocart" Text="Add To Cart" CommandName="AddToCart" ItemStyle-CssClass="btnCol" /> If someone could please help me that would be great thanks.

    Read the article

  • why my form is doing postback when i am calling asynchronously?

    - by Abu Hamzah
    i am using simple asp.net webpage with few fields on it and when the user click on submit button i am calling asynchronously and posting the data. BUT, my whole page is posting back and i dont even see the message that i am trying to display if my data got posted succfully. here is my page. Requester Page Name: <asp:Label runat="server" ID='Label4' >Host Name:</asp:Label> <asp:TextBox ID="txtHost" runat='server'></asp:TextBox> <asp:Label runat="server" ID='Label2' >Start Date:</asp:Label> <asp:TextBox ID="txtStartDate" runat='server' ></asp:TextBox> <asp:Label runat="server" ID='Label6' >End Date:</asp:Label> <asp:TextBox ID="txtEndDate" runat='server' ></asp:TextBox> <ul> <li> <button id="btnCancel" name="btnCancel" type="button"> Cancel</button></li> <li> <button id="btnReset" name="btnReset" type="reset"> Reset</button></li> <li> <button id="btnSubmit" name="btnSubmit" type="submit"> Submit</button></li> </ul> </p> </form> </div> //Store new Contract Request Methods function processCompletedContactStore(response) { if (!response) { showErrorMsg('No Contacts Returned'); return; } else { if (response.Message == 'update') { $("#status").fadeTo(500, 1, function() { $(this).html("Updated successfully!").fadeTo(500, 150); }) } } }

    Read the article

  • ASP.NET C# DataList FindControl & Header/Footer template causes error

    - by m3n
    Hello, whenever I use the Header or Footer template of DataList, FindControl is unable to find a label part of the DataList, and throws a NullReferenceException. My SQLDataSource and DataList (no Header and Footer template - works): <asp:SqlDataSource ID="sdsMinaKop" runat="server" ConnectionString="<%$ ConnectionStrings:dbCSMinaKop %>" SelectCommand="SELECT kopare_id, bok_id, bok_titel, bok_pris, kop_id FROM kop WHERE kopare_id = @UserName" onselecting="sdsMinaKop_Selecting"> <SelectParameters> <asp:Parameter DefaultValue="admin" Name="UserName" /> </SelectParameters> <asp:SelectParameters> <asp:Parameter Name="UserName" Type="String" /> </asp:SelectParameters> </asp:SqlDataSource> <asp:DataList ID="DataList1" runat="server" DataKeyField="kop_id" DataSourceID="sdsMinaKop" onitemdatabound="DataList1_ItemDataBound" RepeatLayout="Table"> <ItemTemplate> <tr> <td><asp:Label ID="bok_titelLabel" runat="server" Text='<%# Eval("bok_titel") %>' /></td> <td><asp:Label ID="bok_prisLabel" runat="server" Text='<%# Eval("bok_pris") %>' /> kr</td> <td><a href="avbestall.aspx?id='<%# Eval("kop_id") %>'" />[X]</a></td> </tr> </ItemTemplate> <ItemStyle Wrap="False" /> </asp:DataList> With Header & Footer template - does not work. <asp:DataList ID="DataList1" runat="server" DataKeyField="kop_id" DataSourceID="sdsMinaKop" onitemdatabound="DataList1_ItemDataBound" RepeatLayout="Table"> <ItemTemplate> <tr> <td><asp:Label ID="bok_titelLabel" runat="server" Text='<%# Eval("bok_titel") %>' /></td> <td><asp:Label ID="bok_prisLabel" runat="server" Text='<%# Eval("bok_pris") %>' /> kr</td> <td><a href="avbestall.aspx?id='<%# Eval("kop_id") %>'" />[X]</a></td> </tr> </ItemTemplate> <ItemStyle Wrap="False" /> <HeaderTemplate> a </HeaderTemplate> <FooterTemplate> a </FooterTemplate> </asp:DataList> Selecting event: protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) { Label pris = (Label)e.Item.FindControl("bok_prisLabel"); LabelTotalt.Text = (Convert.ToDouble(LabelTotalt.Text) + Convert.ToDouble(pris.Text)).ToString(); } Why would this happen? Thanks

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >