Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x

ASP.NET

124K

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

I have been trying to figure out how to bind sql data to a radCombo box that is nested within a radGrid's automatic Edit Form.
Oddly enough, I was able to figure out how to "cascade" the radCombo boxes Department & ActivityNum as shown in the screenshot.  What I have not figured out is how to initially bind ActivityNum onDataBound.  The exact problem I am having right now is that the following line results in cboActivityID=Nothing resulting in the errors in the screenshots below...

Dim cboActivityID As RadComboBox = e.Item.FindControl("cboActivityNum")

editForm
ss.PNG
error.PNG
.aspx
<telerik:RadGrid ID="grdDetail" runat="server" CellSpacing="0" DataSourceID="sqldsDetail" DataKeyNames="TID" GridLines="None" Skin="Telerik" Height="350px" AllowSorting="True" AllowAutomaticUpdates="True" >
            <GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
        <ClientSettings>
            <Selecting AllowRowSelect="True" />
            <Scrolling UseStaticHeaders="True" AllowScroll="True"/>
            <Resizing AllowColumnResize="True" />
        </ClientSettings>
        <MasterTableView AutoGenerateColumns="False" DataSourceID="sqldsDetail" DataKeyNames="TID" EditMode="EditForms" AllowAutomaticUpdates="True">
            <RowIndicatorColumn Visible="true">
            </RowIndicatorColumn>
            <ExpandCollapseColumn Created="True">
            </ExpandCollapseColumn>
            

Open in new window

0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Example simplified/contrived for this question. Recently, I came across following code sample.
There is a Js helper file defined as function() JsHelper and there are bunch of other methods created and defined
as JsHelper.prototype.... .

In the view code under document ready function, a new helper is created --> helper = new JsHelper();

My understanding is JsHelper object is created (even though , it is a function but can be used as a object).
and when once created it will execute all the code within the JsFile, is this right?

and also, in the JsHelper function, a variable me is assigned to this? how does it work?

-----------razor view code ------------------
<script>
       $(document).ready(function () {
            helper = new JsHelper();
        });
</script>


----------JsFile ---------------------
function JsHelper(){
    var me = this;
   
     meElements = $("#form").find("input");
     
      me.dosomething ();
}

JsHelper.prototype.dosomething = function (){
     var me = this;
       $("#div").each( function () {
             //do sth with the elements
        });
}
0
I have an ASP.Net MVC web application. I have several views and controllers. How do you change what controller a view is tied too? For example, I created a view that referenced code in the HomeController. I created a new controller to house that code only, but I can't get the view to use the new controller instead of the HomeController. I hope that makes sense. Thanks for any help.
0
Hi,
I cannot show the message prompt properly, by the following. Why?

function showMsg0() {
    $.message({
        title: '信息',
        content: 'new或NEW是保护字,不可以选为名字简称!',
        buttons: {
            OK: {
                text: 'OK',
                btnClass: 'btn-green',
                keys: ['enter'],
                action: function () {
                    //$.alert('You clicked OK!');
                }
            },
        }
    });
    return false;
};
...
        protected void userabbr_post_change(object sender, EventArgs e)
        {
            if (tb_userabbr.Text.ToUpper() == "NEW")
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showMsg0()", true);
                tb_userabbr.Text = "";
                return;
            }
        }

Open in new window

0
Hi

I am looking for a Microsoft Cloud accounting system for a small operation.
I need to be able to send data to the accounting system from an ASP.net web app.
Is this possible with Microsoft Dynamics?
If not is there a better option?
Thanks
0
Can someone tell me where is the ASP.NET Core Web Application template?
It's there for C# but is missing for VB.NET
1
Hi,
I use Dropzone to upload the files to the site.
http://www.dropzonejs.com/#events

  
			<form id="upload" method="post" action="Docs.aspx" enctype="multipart/form-data">
			<div id="drop">
				Drag & Drop Here

				<a>Browse</a>
				<input type="file" name="upl" multiple />
			</div>

			<ul>
				<!-- The file uploads will be shown here -->
			</ul>

		</form>

Open in new window

this is the code behind

    protected void Page_Load(object sender, EventArgs e)
    {
        



        bool exists = System.IO.Directory.Exists(Server.MapPath("~/DocStorage/File-" + Session["sCMID"]));
        if (!exists)
            System.IO.Directory.CreateDirectory(Server.MapPath("~/DocStorage/File-" + Session["sCMID"]));

        DirectoryInfo flDis = new DirectoryInfo(Server.MapPath("~/DocStorage/File-" + Session["sCMID"]));

        foreach (string s in Request.Files)
        {
            HttpPostedFile file = Request.Files[s];
            int fileSizeInBytes = file.ContentLength;
            string fileName = file.FileName;
            string fileExtension = "";


            if (!string.IsNullOrEmpty(fileName))
                fileExtension = Path.GetExtension(fileName);
            string savedFileName = Guid.NewGuid().ToString() + fileExtension;
            //string savedFileName = fileName;

            string filename = Server.MapPath("~/DocStorage/File-" + Session["sCMID"] + "/" ) + savedFileName;
            

            file.SaveAs(filename);
            
        }

Open in new window

0
Hi Guys,

I have an asp.net application and I authenticate users by using <authentication mode="Windows">.

The users are active directory users and they are login to their machine with the same credentials they log in to the asp.net application.

My question is how can I check in my asp.net application that user already login to his machine and let him login automatically to the application.

Thanks.
0
what are difference between http post and get, as far as what/how data is passed in a http request.
Reason I'm asking is, I created a simple ASP.NET MVC application. I have two methods (shown below, example contrived for this question). one method is decorated with [HttpPost] and other one is not. when i make a call from a third party app, it hits the break point in the first function ProcessData1 and I get the id parameter as well, since it is being passed in query string.
but if i try to make a call to ProcessData2, it doesn't hit the break point in that function.
I know the third party application, I'm using is making a Http post call.
I tried another rest client and this time when I made a call to ProcessData2, it was successful.

can some one point out possible reasons?

        public ActionResult ProcessData1(string id) {          
            return View(request);
        }

       [HttpPost]
        public ActionResult ProcessData2() {          
            return View(request);
        }
0
say, I have an IFrame integration with an another website. when my site opens in this IFrame, i can make few JS calls to get the data from another site.

once I have the data (string data), I populate a hidden field in my page with this data. Now, how do i post this back to my controller, or what are few ways to do this?

can it be a ajax call ? so far, what I have in my html page is, a script that runs as soon as the page loads

 
<script type="text/javascript">
    (function () {
        try{
                document.getElementById("data").value = GetData();
            }
        }
        catch (e) {
            alert("error");
        }
    })();
</script>

Open in new window

0
Industry Leaders: We Want Your Opinion!
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Hi,

I am using gridview and i am loading more than 20,000 (twenty thousand records) records at a time.

when i click the sorting for the parrticular column, i am getting page cannot be displayes.

if i load less than 10,000 records then the sorting working fine.

what is the problem in the gridview..?
0
Hi All

I am clearly missing something here. I am trying to send calls to an API for a product called ServiceDeskPlus.

The operation name "ADD_REQUEST"  should be sent as a "POST attribute" with key "OPERATION_NAME".

The technician key should be sent as a "POST attribute" with key "TECHNICIAN_KEY".

Input is an XML string sent as a "POST attribute" with key "INPUT_DATA".

The full documentation page is found here.

The code I am using to create the Post Attributes is:
public void CreateSupportDeskItem(ref SupportItem supportItem, string clientCode = "")
        {
            string destinationUrl = Properties.Settings.Default.ServiceDeskEndPoint;
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(destinationUrl);

            string group = Properties.Settings.Default.ServiceDeskGroup;
            string status = Properties.Settings.Default.ServiceDeskStatus;
            string service = Properties.Settings.Default.ServiceDeskService;
            string technicianKey = Properties.Settings.Default.ServiceDeskAPIKey;

            string requestXml;

            if (string.IsNullOrEmpty(clientCode))
                requestXml = GenerateRequestXml(supportItem,
                                         group, status, service);
            else
                requestXml = GenerateRequestXml(supportItem, group, status, service, clientCode);

    

Open in new window

0
I have an ASP.Net Core 2.0 web application that calls a Web API in a different project. When I try to run it I get the error An unhandled exception occurred while processing the request. Further detail leads to this: WinHttpException: A connection with the server could not be established. I have not run into this yet. The code for the controller is below. It erros out on this line:
HttpResponseMessage Res = await client.GetAsync("api/players");

Open in new window


Here is my HomeController.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using MyAPIClient.Models;
using Newtonsoft.Json;

namespace MyAPIClient.Controllers
{
    public class HomeController : Controller
    {
        string Baseurl = "http://localhost:60000/";
        public async Task<ActionResult> Index()
        {
            List<Player> PlayerInfo = new List<Player>();

            using (var client = new HttpClient())
            {
                //Passing service base url  
                client.BaseAddress = new Uri(Baseurl);

                client.DefaultRequestHeaders.Clear();
                //Define request data format  
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                //Sending request to find web api REST service resource GetAllPlayers using HttpClient 

Open in new window

0
Hi,

I am trying to see if I could set the fixed width in GridView. This is what I use based on searching on Internet.

                    <asp:TemplateField HeaderText="Work Phone" SortExpression="WorkPhone" HeaderStyle-Width="20%">
                        <ItemTemplate>
                            <asp:Label ID="WorkPhone" runat="server" Text='<%#Eval("WorkPhone")%>' />
                        </ItemTemplate>
                    </asp:TemplateField>

Open in new window


But it does not work. Am I missing something? thanks
0
pennlive.com
cleveland.com
nola.com

are 2 news websites that look very similar

do they use the same software

what content management system do you think they use
0
Dear Experts,
Good day,

I am working on Reservation system, where i wrote a code if that record date gets equal to current date ... then
Just insert the same record one more time in DB, code is written below but i have a general question ....

It works fine if i stay on that page, but what if the page is not open and i would like to generate that event behind the scene.
I hope you got my idea ....
I do not want to be on the page to let that event trigger, i just want when some particular time which i will mention if arrives record inserted int DB.

I am using Asp.net VB and MS ACCESS as DB. PLS HELP

      If Convert.ToDateTime(mytxtboxdepart.Text) > Convert.ToDateTime(mytxtarrivon.Text) And mynightrun = Now.ToLocalTime.ToLongTimeString Then
                    'MsgBox(txtBoxTimer.Text & " = " & Now.ToLocalTime.ToLongTimeString)

                    Me.myAccessConnection.ConnectionString = Me.connStr
                    Me.myAccessConnection.Open()
                    command.CommandText = "insert into ReservationTb([confirmid],[Gname],[ArrivalOn],[Departure],[Nights])values (confirmid,Gname,ArrivalOn,Departure,Nights)"
 end if
0
I have read everything I can get my hands on about ViewState but can't seem to figure out what I'm doing wrong.

In a sub routine that first and foremost fills a grid, I set the value of two controls and then save those to view state:

                    ViewState.Item("SortKey") = SortKey.Value
                    ViewState.Item("RecId") = RecId.Value

I'm using ViewState because I can't seem to get the control values to persist.

On Page_Load I try to retrieve those values into the controls:
            SortKey.Value = ViewState.Item("SortKey")
            RecId.Value = ViewState.Item("RecId")

This does not work.

What am I missing?


Thanks
0
1. I have a page with some fields like first name, last name, address, city, etc.

2. Some fields are required and some aren't.

3. On the page, I want to have 2 buttons; "Save for later" and "Save & Submit"

4. I created two tables with the same fields. In one table (for Save-for-Later"), I have the fields as nullable.
     In the real table (table for Save & Submit), I have the required fields as non-nullable and the non-required ones as nullable.

So, I have 2 tables. I wonder if this is a good design. If I want to display ALL the data (complete and incomplete) in a table, I have to go to two tables and get the data. Maybe I need a "complete" flag?

Maybe I just need one Save-For-Later table and have all the fields as nullable. When user clicks on "Save & Submit".... I insert the row from one table to the other?

Any ideas or is my orig design idea is good?
0
I'm going to have a page that contains many gridview controls. I'm trying to create a custom sort method for my GridView controls. I have an organic example that works just fine in my code.

        protected void myGridViewControl_Sorting(object sender, GridViewSortEventArgs e)
        {
            //PSUEDO CODE NOT WRITTEN FOR CORRECTNESS
            DataSet myDataSet = new DataSet();
            myDataSet  = myGridViewControl.Sort(someData, e.SortExpression).ToList();
        }

Open in new window


...and this works fine. So I try to then, I add another grid view control and use that grid's OnSorting method to pass the GridView control to my custom method. In essence, passing my grid and its GridViewSortEventArgs to my new global sorting method:

        protected void dtgClinicScheduledEvents1_Sorting(object sender, GridViewSortEventArgs e)
        {
            SortAllGrids(sender, e);
        }
.
.
.
        protected void SortAllGrids(object sender, GridViewSortEventArgs e)
        {
            GridView gridView = (GridView)sender;
            string strID = gridView.ID;

            myCustomCollection myLocalColletion= new
                               myCustomCollection().BinaryDeserialize(Session[mySessionVariable] as string);
            myLocalColletion.AccecptColletion = gridView.Sort(myLocalColletion.AccecptColletions, gridView.SortExpression).ToList();
            Session[mySessionVariable] = myLocalColletion.BinarySerialize();
        }

Open in new window



I'm getting a few errors in my custom sort method that I don't understand. If you can accept that the 1st line of code and the 3rd line of code (marked above with 1 and 3) are correct, then the compile time errors I'm getting are as follows:
  1. Now, my "myLocalColletion.AccecptColletions" object is telling me that the 1st parameter of the grid's sort method, needs to be a string? Why

2. My second parameter now is now expected to be a string. Why is it no longer a string, it was before in the "organic" Sorting method.

3. Lastly, the "." is error-ing out at compile time telling me that: "Operator "." cannot be applied to operand of type" void'". Again, this was not the case before, so why is it now?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE
LVL 5
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

I need to build a custom sort method for a GridView control, but I'm having trouble properly accessing the grid ID and the sort expression. Can some one give me an example of a custom sort method or links to one? I have to add many grids to my page and they all need to be sortable through one method.


        private void SortAllGrids(object sender, GridViewSortEventArgs e)
        {
            GridView gridView = (GridView)sender;
            string test = gridView.ID;           
        }

Open in new window

0
Hi Guys,

I'm trying to find a way to develop SSO for my company.
We have two web applications which developed by ASP.NET.

I will be happy with your recommendations.

Note: please if you can refer to how to develop SSO with .NET technology as ASP.NET, MVC.

Thank you.
0
I am programming in C#. I have some data that I want to write to an HTML file as a table of 3 columns and an unknown number of rows.

Then I display that file in a web browser.

Currently this is all done by brute force. The C# code writes out the <HTML> tag and all the following header tags. It writes the <TABLE> tag. It loops through the data, writing each line of the table, adding appropriate <TR>...</TR> and <TD>...</TD> tags. It then closes the table with a </TABLE> tag, writes some footer information, and finally ends the file with a </HTML> tag.

There's got to be a better way.

This code works, but it's difficult to maintain.

I know PHP has a nice way of dealing with this, But I'm not using PHP, I'm using C#.

I've seen XSLT transformations that outputs nice HTML code, but my input isn't XML.

Is there a good way to deal with this in C#? Where I can create some sort of template that's easy to understand and maintain? A template that conveys the idea, "I want the output to be a HTML file which has a table of 3 columns"?
0
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim cell As TableCell = e.Row.Cells(4)
            Dim cell2 As TableCell = e.Row.Cells(6)
            Dim mytxtboxdepart As TextBox = e.Row.FindControl("txtBoxDeparture")
            Dim mytxtboxstays As TextBox = e.Row.FindControl("txtBoxStays")
            Dim mytxtboxcriteria As TextBox = e.Row.FindControl("txtBoxCriteria")

            Dim provider As String
            Dim connString As String
            Dim myconnection As OleDbConnection = New OleDbConnection
            provider = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("~/App_Data/myDB.mdb")
            connString = provider
            myconnection.ConnectionString = connString

            If Convert.ToDateTime(mytxtboxdepart.Text) < Convert.ToDateTime(mytxtboxstays.Text) Then
                myconnection.Open()
                Response.Write(Convert.ToDateTime(mytxtboxdepart.Text))
                cell2.BackColor = Color.Red
                Dim str As String
                str = "DELETE * FROM ReservationTb WHERE Criteria" = "5"
            End If
            command.Connection = myAccessConnection
            command.ExecuteNonQuery()
            myAccessConnection.Close()
        End If
    End Sub

But i am getting the error ...
0
Im having trouble with displaying the information with repeater, this is done with 2 projects, company and supplier. i used web service to get the information from supplier to company.

Error: the name 'dae does not exist in the current context' (.cs page at the company side)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PawsPawsMock.BLL;
using System.Data;
using System.Data.SqlClient;

namespace PawsPawsMock
{
    public partial class AdminECatalog : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindEventRepeater();
            }
        }
        private void BindEventRepeater()
        {
            BllCompEventCatalog eve = new BllCompEventCatalog();
            DataSet ds = new DataSet(); 
                DataTable dte = new DataTable();
                dae.Fill(dte);
                rptrEvents.DataSource = dte;
                rptrEvents.DataBind();
        }
    }
}

Open in new window

the aspx page(source):
 <asp:Repeater ID="rptrEvents" runat="server">
            <ItemTemplate>
                <div class="col-sm-3 col-md-3">
                    <div class="thumbnail">
                        <!--Add image here--->
                        <div class="caption">
                             <div class="proName"><%#Eval("EName") %></div>
                            <div class="proPrice"><span class="proOgPrice"><%#Eval("EPrice") %></span> <%#Eval("ESelName") %><span class="proPriceDiscount">(201 Off)</span></div>
                        </div>
                    </div>
                </div>
            </ItemTemplate>
        </asp:Repeater>

Open in new window

0
Dear Experts,
I hope i will get the answers of my question by today ..
I am working on Hospitality Management Software, of which 70% is done only Billing Section's few part left .. and thats where i am stuck. I am using Asp.net VB & MS Access as back-end.
My Requirement i would like to take a value when a NEW RESERVATION will be made "Arrival on" to "Departure"
Right now i just can save 2 values which is Arrival date & Departure date in database but i want something like this as below ...
so what i need i am giving you idea in DB actually how it goes ....

id    confirmid   name     arrivalon     departure         currentdate
1      1111           ABC       01/3/2018   01/05/2018       01/3/2018
2      1111           ABC       01/3/2018   01/05/2018       01/4/2018
3     1111           ABC       01/3/2018   01/05/2018       01/5/2018   ------> if this equals departure date ABC  CHECK OUT
4      2222           XYZ        01/3/2018   01/04/2018       01/3/2018
5      2222           XYZ        01/3/2018   01/04/2018       01/4/2018    ------> if this equals departure date XYZ CHECK OUT

so my problem is i just can save arrival on & departure first row which is id 1, the remaining id 2 & & 3 how can i save,
Similarly id 4 is saved when i make a new reservation the id 5 how can i save.

PLS HELP ... I NEED MY PROJECT TO FINISH IT BY A NEXT WEEK, THANKS IN ADVANCE
0

ASP.NET

124K

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