ASP.NET

125K

Solutions

28K

Contributors

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi

In an ASP.net GridView template column if I hit Enter it causes a postback.
Is there a way to prevent this?

Thanks
0
Hi

I have an ASP.net Gridview that contains Template TextBox columns
I want to loop through and check the text box text and tooltip text
How do I do this in the following code? The sort of template columns are shown
below

            For i As Integer = 0 To Me.GridView1.Columns.Count - 1
                oColIndex = i + 2
                For r As Integer = 0 To Me.GridView1.Rows.Count - 1
                           'I need to gather the text box value and tooltip here
                Next r
            Next i

Open in new window


     <asp:TemplateField HeaderText="D1" Visible="false" ItemStyle-Wrap="true" >
                           <ItemTemplate>
                                <asp:Textbox ID="D1" runat="server"  Visible="true" Width="20"></asp:Textbox>
                           </ItemTemplate>
                      </asp:TemplateField>
                      <asp:TemplateField HeaderText="D2" Visible="false" ItemStyle-Wrap="true" >
                           <ItemTemplate>
                                <asp:Textbox ID="D2" runat="server"  Visible="true" Width="20" ></asp:Textbox>
                           </ItemTemplate>
                      </asp:TemplateField>
                     <asp:TemplateField HeaderText="D3" Visible="false" ItemStyle-Wrap="true">
                           <ItemTemplate>
                                <asp:Textbox ID="D3" runat="server"  Visible="true" Width="20" ></asp:Textbox>
                           </ItemTemplate>

Open in new window

0
I am using datetimepicker.js to enter dates, my problem is the pop up seems to be positioned by screen position rather than window position and in chrome pops up behind the window not on top...

My Configured variables

;
var WeekDayName1=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var WeekDayName2=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];
var exDateTime;//Existing Date and Time
var selDate;//selected date. version 1.7


//Configurable parameters
var cnTop="200";//top coordinate of calendar window.
var cnLeft="500";//left coordinate of calendar window
var WindowTitle ="Date Picker";//Date Time Picker title.
var WeekChar=3;//number of character for week day. if 2 then Mo,Tu,We. if 3 then Mon,Tue,Wed.
var CellWidth=20;//Width of day cell.
var DateSeparator="/";//Date Separator, you can change it to "/" if you want.
var TimeMode=24;//default TimeMode value. 12 or 24

var ShowLongMonth=true;//Show long month name in Calendar header. example: "January".
var ShowMonthYear=true;//Show Month and Year in Calendar header.
var MonthYearColor="#cc0033";//Font Color of Month and Year in Calendar header.
var WeekHeadColor="#0099CC";//Background Color in Week header.
var SundayColor="#6699FF";//Background color of Sunday.
var SaturdayColor="#CCCCFF";//Background color of Saturday.
var WeekDayColor="white";//Background color of weekdays.
var FontColor="blue";//color of font in Calendar day cell.
var 

Open in new window

1
In my ASP.net GridView I previously used the following code to make cells clickable.
How can I use similar code to  change the cells color on mouseout

    Private Sub GridView1_RowCreated(sender As Object, e As GridViewRowEventArgs) Handles GridView1.RowCreated


        If e.Row.RowType = DataControlRowType.DataRow Then
            'Following link shows how cells are made clickable
            '//https://stackoverflow.com/questions/31202877/get-clicked-cell-index-in-gridview-not-datagridview-asp-net
            For i As Integer = 0 To e.Row.Cells.Count - 1
                Dim cell As TableCell = e.Row.Cells(i)
                cell.Attributes("onmouseover") = "this.style.cursor='pointer';this.style.textDecoration='underline';"
                cell.Attributes("onmouseout") = "this.style.textDecoration='none';"
                'cell.ToolTip = "You can click this cell"
                cell.Attributes("onclick") = String.Format("document.getElementById('{0}').value = {1}; {2}", SelectedGridCellIndex.ClientID, i, Page.ClientScript.GetPostBackClientHyperlink(CType(sender, GridView), String.Format("Select${0}", e.Row.RowIndex)))
            Next
        End If


    End Sub

Open in new window

0
Hi

I have 30 template textbox columns in an ASP.net GridView, some of which are shown in the code below. If any text is changed
in these textboxes I want to change the background color of the textbox . What VB.net code would I use to do this?

Thanks

     <asp:TemplateField HeaderText="D1" Visible="false">
                           <ItemTemplate>
                                <asp:Textbox ID="D1" runat="server"  Visible="true" Width="20"></asp:Textbox>
                           </ItemTemplate>
                      </asp:TemplateField>
                      <asp:TemplateField HeaderText="D2" Visible="false">
                           <ItemTemplate>
                                <asp:Textbox ID="D2" runat="server"  Visible="true" Width="20" ></asp:Textbox>
                           </ItemTemplate>
                      </asp:TemplateField>
                     <asp:TemplateField HeaderText="D3" Visible="false">
                           <ItemTemplate>
                                <asp:Textbox ID="D3" runat="server"  Visible="true" Width="20" ></asp:Textbox>
                           </ItemTemplate>
                      </asp:TemplateField>

Open in new window

0
Hi

I use the following VB.net code to populate textbox cells in my ASP.net GridView columns.
I also need to store a unique ID value for each cell. I am currently using the ToolTip to do this
Is there another way that I can embed my ID value in each cell?

    Private Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GridView1.RowDataBound

        Dim oColIndex As Integer
        Dim oDate As String
        Dim oEachDate As Date
        Dim oTemplateColumn As String
        Dim oDateList As String = TryCast(Session("oDateList"), String)
       Dim oLineID_PlusDate As String 'this is eg Line ID 19 apr 2019
        Dim arrDates As Object = Split(oDateList, ",")
        For i As Integer = 0 To UBound(arrDates)
            oColIndex = i + 2
            oTemplateColumn = "D" & CStr(i + 1)
            oEachDate = CDate(arrDates(i))
            oDate = oEachDate.ToString("dd MMM yyyy")
            Me.GridView1.Columns(oColIndex).Visible = True
            If e.Row.RowType = DataControlRowType.Header Then
                Me.GridView1.Columns(oColIndex).HeaderText = oDate
            End If

            'Me.GridView1.Columns(2).Visible = True
            If e.Row.RowType = DataControlRowType.DataRow Then
                Dim D1 As TextBox = CType(e.Row.FindControl(oTemplateColumn), TextBox)
                If Not IsDBNull(e.Row.DataItem(oDate)) Then
                    D1.Text = e.Row.DataItem(oDate)
                End If
 …
0
Hi.  I am trying to change the header text of template columns in a GridView in ASP.net using the following VB.net code but for some reason the
headers are not changing

    Private Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GridView1.RowDataBound
        For i As Integer = 0 To UBound(arrDates)
            oColIndex = i + 2
            oTemplateColumn = "D" & CStr(i + 1)
            oEachDate = CDate(arrDates(i))
            oDate = oEachDate.ToString("dd MMM yyyy")
            Me.GridView1.Columns(oColIndex).Visible = True
            If e.Row.RowType = DataControlRowType.Header Then
                Me.GridView1.Columns(oColIndex).HeaderText = oDate
            End If
        End if
Ebd Sub

Open in new window

0
Hi
I have the following two ASP.net GridVidew template columns
The first binds to EmloyeeName but the second has to bind to various
other columns. What VB.net code would I use to bind that column programatically?

              <asp:TemplateField HeaderText="Employee Name" Visible="true">
                           <ItemTemplate>
                                <asp:Label ID="lblEmployeeName" runat="server" Text='<%# Bind("EmployeeName")%>' Visible="true"></asp:Label>
                           </ItemTemplate>
                      </asp:TemplateField>
                      <asp:TemplateField HeaderText="T2" Visible="true">
                           <ItemTemplate>
                                <asp:Textbox ID="T2" runat="server"  Visible="true" Width="10"></asp:Textbox>
                           </ItemTemplate>
                      </asp:TemplateField>

Open in new window

0
I am using ASP.NET MVC 5 with entity framework 6 and a SQL 2014 database to create a customer relationship management system. I want to add the capability to upload and download attachments to the meeting. With the code below, I have a browse button and can browse to the files, but it is not saving to the folder in the Solution and is not saving the path to the database.

In my mind, The create view of the MeetingsController creates the meeting and allows uploading attachments. The Meeting Details view shows the meeting information as well as a link to download the related attachments. This is working off of an existing database that was used for a desktop application. I want to make this a website for my end users. I used database first methodology to create the scaffolding for controllers and views.

Here is the HttpPost for the Create action in the MeetingsController:

 [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "Id,InteractionDate,Notes,approval_status_id,CustomerCallDecisionedBy,CustomerCallDecisionDate,BankOfficer,TrustOfficer,Customer,Employee,IsDeleted,IsReview")] Meeting meeting, HttpPostedFileBase upload)

        {
            if (ModelState.IsValid)
            //Add upload capability to the create meeting view
            {
                List<Attachment> attachments = new List<Attachment>();
                for (int i = 0; i <Request.Files.Count; i++)
                {
                    var 

Open in new window

0
I was up and running using Microsoft Visual Studio 2013, and had no problems generating a build or published web application.  I was upgraded to
Microsoft Visual Studio 2017 and now can still do a build successfully, and run a local copy of my application.  However, now when I attempt to
publish, the published version does not work and fails  I noticed in the published code apsx pages, the <% page directive has been corrupted.

Alll aspx. pages have corrupted page declaration. Inherit parameter has gibberish in it, and the codebehind has disappeared.

Any idea on how to fix this issue?  I got a copy of Microsoft Visual Studio 2013 and ran a publish and it was fine.  However, do not have a permanent
licensed copy of 2013 but I now have for 2017 but it won't publish.
0
Hi. In my ASP.net project I need to add a handler as follows.  Where should I put this? In the page load event?

' Hook up RowIslandDataBound event
AddHandler Me.WebHierarchicalDataGrid1.RowIslandDataBound, AddressOf WebHierarchicalDataGrid1_RowIslandDataBound
Protected Sub WebHierarchicalDataGrid1_RowIslandDataBound(ByVal sender As Object, ByVal e As RowIslandEventArgs) Handles WebHierarchicalDataGrid1.RowIslandDataBound
   If e.RowIsland.DataMember = "SqlDataSource1_DefaultView" Then
      ' Access a PARENT cell value
      Dim cellValue As String = e.RowIsland.Rows(0).Items(1).Value.ToString()
   End If
End Sub

Open in new window

0
Default page has
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MainOptionsTwo.aspx.cs" Inherits="CLEEPMedic.MainOptionsTwo" %>
<%@ OutputCache Location="Any" Duration="60" VaryByParam="none" VaryByControl="none" %>

Open in new window


The Default page loads Caches from database.  
On click event Response.Redirect("frmPCRPreHospDisplayEditr.aspx", false);  Page Two loads and uses Caches for filling listboxes.

If I use the back button to return to Default page, I can then return to Page Two, which fills normally. The back button always works.  

However from Page Two, if I use  Response.Redirect( "Default.aspx",false);  I return to the Default page , but am "stuck" on the Default page.  By stuck, I mean no click event works;  and not will work for the Duration set in OutputCache.  

If I change the Duration to 5, then the Default page clicks works in 5 seconds.   Until the duration expires, the click event causes some kind of refresh, but breaks placed throughout code are never hit.   Curious as how the Duration can affect the page behavior.  

 Thanks,
V Whitehead
0
Is there a way to route an API post to another external API endpoint.

I work for a franchisor and our franchisees opt in to utilizes the different tools and services to run their franchise.

 I have a situation where we have an exclusive API access to one of our vendors web applications (its very similar to a CRM but it also has employees scheduling, etc).  This API grants us access to all of our franchisees data.

We have another vendor that offers drip marketing to our franchisees.  They do not work with all of our franchisees.  

I need to give the drip marketing vendor access to the CRM API but only for the franchisees that they work with.  The only way that IU can think of doing this is to:

 - Create a database that contains a list of franchisees that they have access to
 - Create different Queuing Tables for the different POST request.
 - Create a custom app process the POST request (run every minute to see if their are new request) .
 - For GET request.  The CRM vendor gave us access to an AWS Athena database and we are able to download all of the required data to our SQL Server.  The data is 24 hours old

I have setup a WebAPI (Microsoft WebAPI) for the Get request and everything works well.  I have also created the above and custom app.  But I think I am going down the wrong path by creating the Queuing tables being that I would also have to create a separate log to report on the errors.  The Marketing vendor will not know if there are errors on our…
0
Hi

In ASP.net I have an Infragistics  WebDataGrid. I want to run code in the event WebDataGrid1_CellEditing_ExitedEditMode
I having changed certain behavior items as per the image below
I just need a little guidance as to what code to put into my project and where to put it in order to catch this event programatically

1
1
Try to run "dotnet ef migrations  add Initial"  to migrate the database and create database schema. However, it returns "Build failed" in Visual Code.

Where can I find more hints about what's wrong with the build ?

Thx
0
Hi

I am trialing Ifragistagistics in ASP.net. I have a WebDataGrid. When I edit a cell the following event doesn't fire. Why would that be?

    Private Sub WebDataGrid1_RowUpdated(sender As Object, e As RowUpdatedEventArgs) Handles WebDataGrid1.RowUpdated
        Dim index = e.RowID.Index

    End Sub

Open in new window

0
Hi

I am using the WebDataGrid in ASP.net with  Infragistics. I have managed to bind the following datatable to the WebDataGrid.
and set up the grid to allow the user to edit a cell.

When the user edits a cell I want to run code to make this changes. What event would I use to do this

1
0
Hi. The following code is being used in ASP.net to add a boundfield and then a template field.
What code would you use to add a template field that is also bound

      BoundField bfield = new BoundField();
        bfield.HeaderText = "Name";
        bfield.DataField = "Name";
        GridView1.Columns.Add(bfield);
 
        TemplateField tfield = new TemplateField();
        tfield.HeaderText = "Country";
        GridView1.Columns.Add(tfield);

Open in new window

0
Hi

I have been looking for ways to make an ASP.net GridView editable like a spreadsheet and it does not look possible.
Are there any third party controls that do this and can be purchased by themselves instead of buying a product like Telerik for example?
Thanks
0
Hi. I have an ASP.net GridView that has several template columns like that shown below. A datatable is bound to the GridView
but sometimes one or two of the columns that the template fields bind to are not included in the datatable.
So if the "EmployeeName" column is not in the datatable  there will be an error. The only way that I can think of doing this
is to assign each datatable column to the corresponding gridview template column programatically but I am not sure how to do this

    <asp:TemplateField HeaderText="Employee Name" Visible="true">
                           <ItemTemplate>
                                <asp:Label ID="lblEmployeeName" runat="server" Text='<%# Bind("EmployeeName")%>' Visible="true"></asp:Label>
                           </ItemTemplate>
                      </asp:TemplateField>

Open in new window

0
Hi. In my ASP.net web app I  am trying to add the following class but there is a problem with the word "ITemplate". What is this? How can I fix this?

Public Class TemplateHandler
    Implements ITemplate

    Private Sub InstantiateIn(ByVal container As Control)
        Dim cmd As Button = New Button()
        cmd.ID = "cmd"
        cmd.Text = "HI"
        AddHandler cmd.Click, New EventHandler(AddressOf Dynamic_Method)
        container.Controls.Add(cmd)
    End Sub

Open in new window

0
How can share/re-use the Site.Master with all my applications on my workstation (IISExpress) as well as on my Test and Production servers?

I create an application with the a blank page and published it to the my test server.

How I get my other applications to use the site master of this new application as their site master. Do I create a virtual directory in each application that contains this new application?

What is the best approach?

Thanks
0
Hi

In my ASP.net web app I bind a datatable to a GridView. The number of columns in the datatable differs each time so I can't manually create
template textbox columns. Is it possible to dynamically create textbox columns for every second column.?

Thanks
0
Hi. I use the following code to in my ASP.net web app to allow the user to click a GridView cell that then loads the information
pertaining to that cell to other controls to allow editing. I would like to also make the editing possible in the gridview cell by turning
it into a text box. How would I do that? I cannot use Template columns and AutoGenerateColumns is true

   Private Sub GridView1_RowCreated(sender As Object, e As GridViewRowEventArgs) Handles GridView1.RowCreated

        Dim dtNew As DataTable = TryCast(Session("dtNew"), DataTable)
        If e.Row.RowType = DataControlRowType.DataRow Then
            'Following link shows how cells are made clickable
            '//https://stackoverflow.com/questions/31202877/get-clicked-cell-index-in-gridview-not-datagridview-asp-net
            For i As Integer = 0 To e.Row.Cells.Count - 1
                Dim cell As TableCell = e.Row.Cells(i)
                cell.Attributes("onmouseover") = "this.style.cursor='pointer';this.style.textDecoration='underline';"
                cell.Attributes("onmouseout") = "this.style.textDecoration='none';"
                cell.ToolTip = "You can click this cell"
                cell.Attributes("onclick") = String.Format("document.getElementById('{0}').value = {1}; {2}", SelectedGridCellIndex.ClientID, i, Page.ClientScript.GetPostBackClientHyperlink(CType(sender, GridView), String.Format("Select${0}", e.Row.RowIndex)))
            Next
        End If


    End Sub

    Protected

Open in new window

0
Hi. I am fairly new to JavaScript. How do I step through JavaScript and put line breaks in.
My code resides in an ASP.net VB.net web app

<script type="text/javascript">
        //variable that will store the id of the last clicked row
        var previousRow;
        
        function ChangeRowColor(row)
        {
            //If last clicked row and the current clicked row are same
            if (previousRow == row)
                return;//do nothing
            //If there is row clicked earlier
            else if (previousRow != null)
                //change the color of the previous row back to white
                document.getElementById(previousRow).style.backgroundColor = "#ffffff";
            
            //change the color of the current row to light yellow
 
            document.getElementById(row).style.backgroundColor = "#ffffda";            
            //assign the current row id to the previous row id 
            //for next row to be clicked
            previousRow = row;
        }
     </script>

Open in new window

0

ASP.NET

125K

Solutions

28K

Contributors

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications