Go Premium for a chance to win a PS4. Enter to Win

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

Hi,
I need to the following code to custom function.Any idea appreciate
 if (TxtPostcode.Text == null && string.IsNullOrWhiteSpace(TxtPostcode.Text))
                    {
                        validate = 1;
                    }

                    if (TxtDestinationName.Text == null && string.IsNullOrWhiteSpace(TxtDestinationName.Text))
                    {
                        validate = 1;
                    }

                    if (TxtDestinationDescription.Text == null && string.IsNullOrWhiteSpace(TxtDestinationDescription.Text))
                    {
                        validate = 1;
                    }

Open in new window

0
Ask an Anonymous Question!
LVL 11
Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Hello I have a series of text boxes to record telephone numbers.  Like this:
Phone Number: (<asp:TextBox ID="txtContHomePh1" runat="server" MaxLength="3" Width="32px"></asp:TextBox>
                       )
                       <asp:TextBox ID="txtContHomePh2" runat="server" MaxLength="3" Width="31px"></asp:TextBox>
                       &nbsp;-
                       <asp:TextBox ID="txtContHomePh3" runat="server" MaxLength="4" Width="49px"></asp:TextBox>

Open in new window

txtContHomePh1 is the area code, txtContHomePh2 is for the next 3 number, and txtContHomePh3 is for the last 4 digits. I want a RequiredFieldValidator to make sure the user fills out the boxes.  Can I use just 1 for all 3 textboxes? Or do I have to put one on each text box?
0
Hi,

I am wanting to ultimatly learn ASP.NET core and have found the following course.

https://www.udemy.com/aspnet-mvc-quick-start/

I am looking at this as just an intro type course. To give me an idea of it before going deeper.

I am comming from a C# / Winforms background with no web. To give you a perspective of my knowledge set.

Anyway what I am wondering is how much this would be wasted (if anything) on a learning journey to ASP.NET core.

From what I can see is ASP.NET runs on windows and .NET core can run on other OS besides windows. However what about *all* the rest.

Is ASP.NET Core a superset of ASP.NET. Still has MVC? Do both have angular?

Thanks,

Ward.
0
1. I have this in MVC routeconfig
 public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

           
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );


        }

Open in new window


2. I have this Controller

  // [HttpPost]
        public ActionResult Index(string formId)
        {

            ViewBag.FormId = formId;
            return View();
        }

Open in new window


3. This works and when I get to the controller, I see "formId"'s value. The URL shows as ?/index/1

  $scope.openForm = function (formId) {

            //console.log(JSON.stringify(formId))

          
            window.location = "/displayform/index/?formId=" + formId; //https://stackoverflow.com/questions/37031143/asp-net-angularjs-how-to-click-on-link-and-route-to-controller-method-with-id

        };

Open in new window


How come these don't work...I step thru it and 'formId" comes out as null. I added HttpPost as well to the MVC Controller. what am I missing?


 window.location = "/displayform/index/"+ formId;

Open in new window



window.open('/displayform/index/' + formId, '_self', false);

Open in new window

0
For years we have been using the following vb code in a Classic ASP page to retrieve data from a software product.
To boost performance and get away from Classic ASP, I need to ASHX C# equivalent of the following  

    //set h = CreateObject("MSXML2.SERVERXMLHTTP")
    //h.open"POST", "http://localhost/isapi/webapi.dll"  //this is a software provided dll that accepts xml objects and returns xml response objects
    //h.setOption(2) = 4096
    //h.send(doc)
    //response.Write("<br><textarea rows=\"20\" cols=\"60\">" + h.responseText + "</textarea>");    
    //for each response in h.responseXml.selectnodes("//Response")
    //response.Write("<br><textarea rows=\"20\" cols=\"60\">" + response.xml + "</textarea>");
    //next
runner.txt
0
protected void btnsave_Click(object sender, EventArgs e)
    {
        try
        {
            using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
            using (SqlCommand cmm = new SqlCommand())
            {
                cmm.Connection = cnn;
                cmm.CommandType = CommandType.Text;
                if (btnsave.Text == "Save")
                {
                    cmm.CommandText = "INSERT INTO register_user([name],[email],[email_pass],[panel_pass],[dept])" + "VALUES(@name,@email,@email_pass,@panel_pass,@dept)";
 
                    cmm.Parameters.AddWithValue("@name", txtname.Text.Trim().ToString());
                    cmm.Parameters.AddWithValue("@email", txtemail.Text.Trim().ToString());
                    cmm.Parameters.AddWithValue("@email_pass", txtemailpass.Text.Trim().ToString());
                    cmm.Parameters.AddWithValue("@panel_pass", txtpass.Text.Trim().ToString());
                    cmm.Parameters.AddWithValue("@dept", ddldept.Text.Trim().ToString());
                   
                }
 
                else
                {
                    cmm.CommandText = "UPDATE [register_user] SET name=@name,email=@email,email_pass=@email_pass,panel_pass=@panel_pass,dept=@dept where id=" + ViewState["id"];
 
                    cmm.Parameters.AddWithValue("@name", txtname.Text.Trim().ToString());
                    …
0
I'm looking for a solution and I thought a client side javascript function  will work. This function will assign the text or title value of a tab  to a particular control.
0
I have a label control in my Masterpage and I would like the  text property of tab I click in the child place
assigned to the label in the Masterpage. Please show example.

 <ul class="tabs" id="thistab" runat="server">

                <li class="tab-link current" data-tab="tab-1" id="tab11" data-toggle="tab"><a href="#Person">Personal Info</a></li>

                <li class="tab-link" data-tab="tab-6" id="tab16"><a href="#Info" data-toggle="tab"                <li class="tab-link" data-tab="tab-2" id="tab12"><a href="#Assign" data-toggle="tab" title="Assignment History">Assignment History</a></li>
                <li class="tab-link" data-tab="tab-3" id="tab13"><a href="#Issues" data-toggle="tab" title="Issues">Issues</a>

</ul>

Open in new window

0
Hi All,

Can you help me resolve this issue on button click?

an unknown error has occurred while processing the request on the server. the status code returned from the server was 500
0
I have a side menu and I click on a link. I want to redirect the user to another page and pass a parameter.

1. In Razor, I do this

 <button ng-click="openForm(row.Id)"  class="btn btn-primary btn-border btn-rounded-20 btn-ef btn-ef-4 btn-ef-4b mb-10">{{row.FormName}}<i class="fa fa-arrow-right"></i></button>

Open in new window


2. In AngularJS controller, I have this
 $scope.openForm = function (formId) {

            //console.log(JSON.stringify(formId))

            //$http({
            //        method: 'POST',
            //        url: '/displayform/index',
            //        data: JSON.stringify(formId),
            //        contentType: "application/json",
            //        dataType: "json"

            //}
               
             

            //    ).then(function () { });

          //  window.open('/displayform/index/' + formId, '_self', false);

            window.location = "/displayform/index/?formId=" + formId; 

        };

Open in new window


3. In C# controller
 // [HttpPost]
        public ActionResult Index(string formId)
        {

            ViewBag.FormId = formId;
            return View();
        }

Open in new window


4. The URL looks like this when the user is redirected
http://localhost:63410/displayform/index/?formId=1

Is there a better way of doing this? I wanted the URL to look like this but couldn't get it working...the passed parameter comes out as null http://localhost:63410/displayform/index/1
0
Concerto's Cloud Advisory Services
LVL 5
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Hello. I have a checkbox list. I want to make it required.  Meaning I want the user to check at least one box in the list.  None of the required field validators work for me.  I also tried doing a javascript validator but I couldn't get that to work.  This is my checboxlist code:

<asp:CheckBoxList ID="cblEduAssistPlans" runat="server" SelectedIndexChanged="cblEduAssistPlans_SelectedIndexChanged" AutoPostBack="true">
                       <asp:ListItem>Individualized education program (IEP)</asp:ListItem>
                       <asp:ListItem>Individualized Family Service Plan (IFSP)</asp:ListItem>
                       <asp:ListItem>504 Plan</asp:ListItem>
                       <asp:ListItem>Other</asp:ListItem>
                   </asp:CheckBoxList>

Open in new window

0
I'm using C# in a ASP.NET web application

In my C# code i have this line where I save today's date into a variable.

Todays date is 11/6/2017

With this code below. The value that gets saved in my variable looks like this: 11/6/2017 8:18:23 AM

// save todays date in a variable
DateTime testvar1 = DateTime.Now;

How do I format DateTime.Now so it save all the digits for the month and day.

I want the value saved in the variable to be this:
11/06/2017 8:18:23 AM

If today's date was 9/5/2017 the value saved in the variable would be this:
Basically add the zeros for single digit months and days.
09/05/2017 8:18:23 AM
0
Sample URL's

 /book_tour.aspx?year=2017&tourcode=8240&strdate=18/Jul/2017&endDate=28/Jul/2017&strdept=824070718Z
/book_tour.aspx?year=2017&tourcode=9020&strdate=25/Feb/2017&endDate=05/Mar/2017&strdept=902070225

Our site is a dynamic site where data is pulled through API.

I'm not sure if something has to be tweaked in wordpress or htaccess file. Also another biggest issue is, our organic traffic has dropped 80%, I understand that initially when platform changes, there will be a traffic drop but it's not improving month on month. Did we do something wrong in migration, I'm not sure, Please help.
0
I want to install this

https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome

I get a message that Visual Studio needs to install it.

In VS, I went to Tools --> Extensions and Updates but I dont see "Debugger for Chrome". I searched "online" in the screen

I see these when I search for Chrome

screenshot
0
Hi experts,

When I run the following code as is and enter values, it works:

                For Each row As DataRow In dtCurrentTable.Rows

                    Dim txtsourcen As String = TryCast(row.ItemArray(1), String)
                    Dim txtsourcea As String = TryCast(row.ItemArray(2), String)
                    Dim txtsourcei As Decimal = TryCast(row.ItemArray(3), String)
                    Dim SourceAmount As String = String.Format("{0:C}", txtsourcei)

                    output = "<span style='font-weight:bold;color:#3b3b3b;font-size:12px'>Name: </span>" & txtsourcen & "<br /><span style='font-weight:bold;color:#3b3b3b;font-size:12px'>Address: </span>" & txtsourcea & "<br /><span style='font-weight:bold;color:#3b3b3b;font-size:12px'>Income:</span> " & SourceAmount & "<br />"

                    lblPreviewSourceName.Text += output & "<br />"

                    'lblPreviewSourceName.Text += txtsourcen & "<br />"
                    'lblPreviewSourceAddress.Text += txtsourcea & "<br />"
                    'lblPreviewIncomeSource.Text += txtsourcei & "<br />"


                    'get the values from the TextBoxes

                    'then add it to the collections with a comma "," as the delimited values

                    sc.Add(lblPreviewSourceName.Text)
                    rowIndex += 1
                Next

Open in new window


However, if left blank,

I throws the following error:

Conversion from string "" to type 'Decimal' is not valid.

How do I cast it to avoid this error when left blank?

Thanks in advance
0
Dear,
1. I want to cut highlighted part below
2. Re-locate the button at end of 1st row, to end of 3rd row (of the whole record)

http://my-friend.co/HouseList4/Default.aspx?userid=mc23
19p.png
0
I have a decimal field that holds a percentage value, such as 37.5 or 62.5

I convert that to an integer to remove the decimals. However, it isn't rounding up and down properly when it is .5

37.5 rounds up to 38.
62.5 rounds down to 62.
87.5 rounds up to 88.

Everything else works as expected.

Anyone know why this is and how to fix it?

thanks!
0
When I try to run an ASP.Net Web Application I get the following error.  What is the cause of this?  How do I fix?  This is happening with all of my projects.


Server Error in '/' Application.

Specified argument was out of the range of valid values.
Parameter name: site
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

 Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: site

Source Error:


 An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:



[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: site]
   System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +280

[HttpException (0x80004005): Specified argument was out of the range of valid values.
Parameter name: site]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10042604
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) …
0
Hi, following code is not working VS 2012, it's working on the 2015,
How to work this in the Visual studio 2012
 var query = $"start={startDate.ToUniversalTime():s}&end={endDate.ToUniversalTime():s}";
                var response = await client.GetAsync($"/public/{Version}/jobs?{query}");
0
Free Tool: SSL Checker
LVL 11
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

http://demos.telerik.com/aspnet-mvc/datepicker

I'm using the telerik ui for asp.net mvc datepicker.

Is there a way to prevent user from typing inside the textbox?
So basically they must click on the calendar icon and use the datepicker to select the date
0
 public void databind2()
    {
        SqlCommand Comm1 = new SqlCommand("select FORMAT(deadlineDate,'dd-MM-yyyy') from FormDetails where FormId=" + FormIDs.Client_BulkPostCard + " and Edition_Id='" + Session["Edition_ID"].ToString() + "'", con);
        con.Open();
        SqlDataReader dr = Comm1.ExecuteReader();
        if (dr.Read())
        {
            Label1.Text = dr[0].ToString();          
        }

        DateTime dt1 = DateTime.Parse(Label1.Text);
        DateTime dt2 = DateTime.Parse(DateTime.Now.ToString());

        int days = (dt1 - dt2).Days;

        if (days > 0)
        {
            lblNoOfDays.Text = days + " DAYS LEFT";
        }
        else
        {
            lblNoOfDays.Text = "DEADLINE PASSED";
        }
        con.Close();
    }

Open in new window


The dt1 date is coming from database in the format as dd-mm-yyyy(31-12-17) but the current date which is stored in dt2 is coming from system as dd-mmm-yyyy(01-nov-17)
so it showing error . Please help me solving this issue using Asp.Net
0
Hi,

This what vendor provided to test

Error is :

The remote server returned an error: (401) Unauthorized.

My code

string result = string.Empty;
            try
            {
                // Create Request
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(@"https://api.verilocation.com/public/v1/drivers?id=1093609330685010");
                req.Method = "GET";
                // Create Client
                WebClient client = new WebClient();
                req.ContentType ="application/json; charset=utf-8";
               // req.UseDefaultCredentials = true;
               // req.PreAuthenticate = true;
               // req.Credentials = CredentialCache.DefaultCredentials;

                //req.ContentLength=61;


                req.Credentials = new NetworkCredential("xxx", "xxx111");
               
                   req.Headers.Add("Authorization","Bearer  Y2xpdmUuaG9sZGVuQHN0b25laGFyZHkuY28udWs6bDBnMTV0MWM1");
             //   req.Headers.Add("Authorization","Basic Y2xpdmUuaG9sZGVuQHN0b25laGFyZHkuY28udWs6bDBnMTV0MWM1");
                req.ProtocolVersion =HttpVersion.Version11;
            
                WebResponse response = req.GetResponse();
                string responseData = new StreamReader(response.GetResponseStream()).ReadToEnd();
                MessageBox.Show(responseData.ToString());




              // Assign Credentials
               
                
            }
            catch (WebException 

Open in new window

0
I have an ASP.Net MVC application. One of my views has a input file control that users use to select a file to upload to a database. After the user selects a file but BEFORE they click the upload button, I'd like to run some code from the controller on the file. Is there a way to do this? It's a simple input control: <input type="file" name="postedfile" /> Any help is appreciated.
0
I have a <div> that I load using jquery:
  $("#<divId").load("/controller/action/" + id);
this works perfectly ... ONCE!

if I make a modification to the database (update, delete, add) and call the load function again, I don't see the updates because the second load function never calls the controller!  I'm stumped here!
0
oi type: net localgroup Administrators     and this is the result:

Administrator
QUARTA-MSK\Domain Admins
The command completed successfully.

Open in new window


ok so how to find wich are DOMAIN ADMINS ?? i tried to type: dsa.msc but i receive some error


its a windows server 2012
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