Subscribe: ASP.NET Forums
Added By: Feedage Forager Feedage Grade B rated
Language: English
application  code  net  new  null  page  public string  public  script  select  session  set public  set  string  text 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: ASP.NET Forums

All Forums

All Forums

Last Build Date: Fri, 20 Apr 2018 08:03:46 -0700


Stop Luftes dhe Varferise ne Bote


Stop Luftes dhe Varferise ne Bote,duani njeri-tjetrin ashtu siç ju don ATI ZOT.

Kjo jete qe po jetoni eshte thjeshte nje pasazhe per nje jete me te mire ne AMSHIM !

"Jesus Christ"

What is default font family of hyperlink


Hi All;

I have an MVC project.  It has set its HTML.ActionLinks set to a default font family and size.  I have a button that has been styled to look like a hyperlink.  But there are visible differences in the font family and size of the text indicating the button. 

Here is the code for that button:


I tried to find the style of the a tags in the css pages. but there is no mention of font size or family in all of those styles.

What is the default font size and family used by a link when it is not explicitly set?

Credit card payment using Merchant Account in c# application


I am junior dot net developer, i need one help for to build simple e commerce application.

Trying to apply credit card payment using Merchant Account in application!  Can you please help me out that how can i make basic application for to use credit card payment and have every details of Merchant Account, i just need a system to take credit card payments.

I just want the simple application which can do credit card payments with my Merchant Account details!

Please help me out if you have any solution?!

How to Keep Session Alive Automatically


Hi All,

please help

i just created a web medthod,  am expecting by reassigning the session value it will refresh the session

 [WebMethod(EnableSession = true)]
    public void refresh_session()

    if( HttpContext.Current.Session["userID"]!=null)
            string uid = HttpContext.Current.Session["userID"].ToString();

            HttpContext.Current.Session["userID"] = uid;



and am calling this method from an ajax call periodically

 var HeartBeatTimer;
    function StartHeartBeat()   // note this function is being called by onload method in body tag of this page
        if (HeartBeatTimer == null)
            HeartBeatTimer = setInterval("HeartBeat()", 1000 * 300);

        function HeartBeat() {


                contentType: 'application/json; charset=utf-8',
                url: 'refreshsession.asmx/refresh_session',
                type: 'POST',
                success: function (response) {

                  //  console.log(response.d);

                error: function (xhr, textStatus, err) {


i checked with console.log by returning value form web method it works fine with this call,

but session still expires after 20 minuts, what am doign wrong here?

any other solution to keep session alive till the browser is not closed

i dont want to use set session time out property to change default timeout ie to 30 of 60 minuts etc


Remove script from a page or disable it's creation



i'm creating amp page with I want to use a static master page and a second file that create the content of the page. If i use page_load event, the compiler append at the end of page this script:

Amp forbid custom script and at out of tag head, so i want to remove it. My idea is get all script registered to the page and remove it, or get the html code of the page after the creation, remove the code as a string and set back the page with the code modified. It is possible my solution or it can be done in another way?

Get Emails of all AD Users


Hi there,

In my MVC app, I have an email textbox. How do I to get emails of all AD users and display as auto populate in Email text box? I have seen quite a few posts about getting the email of currently logged in user but nothing about getting  emails of all AD users. Is it possible?


Architecture and implimentation of signed document via USB Token


Hi All,

I am developing an c# web-application to sign documents on the client side.

The client will use an USB dongle to sign the documents.

Any guidence is appreciated. 

chat application in c#


hello please provide some source code of chat application 

AutoCompleteExtender service


I have the following markup in my aspx webforms page to use for autocomplete textbox. I want it to get matching results from an sql stored procedure (also listed below). The stored procedure requires 2 variables and I cannot get it to work. Any help is appreciated.

p.s. If jquery code is better please point me to sample.


Below is my webservice

Imports System.Data.SqlClient
Imports System.Web.Services

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.

Public Class WebServiceFoods
    Inherits System.Web.Services.WebService

    Public Shared Function SearchFoods(ByVal prefixText As String, ByVal count As Integer) As List(Of String)
        Dim lstfoods As List(Of String) = New List(Of String)
        Using conData As SqlConnection = New SqlConnection(DBClass.GetKDConnectionString)
            Dim strSQL As String = "EXEC kd_selFoodItemsSearch @SearchText ='" & prefixText & "'"
            Dim cmd As SqlCommand = New SqlCommand
            cmd.CommandText = strSQL
            cmd.Parameters.AddWithValue("@SearchText", prefixText)
            cmd.Connection = conData
            Dim sdr As SqlDataReader = cmd.ExecuteReader
            While sdr.Read
            End While
        End Using

        Return lstfoods
    End Function

End Class

Below is my stored procedure

ALTER PROCEDURE [dbo].[kd_selFoodItemsSearch]
	@OrgID		int,
	@SearchText nvarchar(100) = null

		IF @SearchText IS NOT NULL
				SET @SearchText = '%' + @SearchText + '%';
		FROM dbo.tblFoods AS F
		WHERE (F.OrgID = 0 OR F.OrgID = @OrgID)
					WHEN @SearchText IS NOT NULL AND F.FoodItem LIKE @SearchText AND (F.OrgID = 0 OR F.OrgID = @OrgID) THEN 'T'
					ELSE 'F'
					END = 'T')
		ORDER BY F.FoodItem;

Using arrayList as DataSource for Gridview


Hi, Im trying to implement this way of populating a gridview but using 2 layer architecture (UI - BO).
BO has 2 class (Person.cs and PersonList.cs)
I want to move the method that create/retrieve the Session to the PersonList.cs and call it from the UI (Default.aspx.cs in the page load). Basically the same as in the page linked but using a layer for the objects (Person and PersonList which retrieves a Session Object populated with a List of Person?). 

connecting WPF client with .NETCore server


I am trying to follow the pattern shown in this question:

AspNetCore.SignalR : Cannot start a connection that is not in the Initial state

where I'm using:


in my WPF client app (.NetFramework 4.7). To do this, it seems to me I need to add a reference to:


in my WPF app.

However, I'm getting this error when I try to build:

System.IO.FileNotFoundException: Could not load file or assembly 'System.Numerics.Vectors, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Am I including the right package for WPF? Or should I be trying to solve the missing file issue? If the latter, how to I get the right file into my build?

How to set selected value from database for Html.DropDownList on pageload?


I am populating a dropdownlist on an edit page from another table called UserAccounts in my database. Once the user is selected from this dropdownlist the selected value gets set as the owner field in the Todo table in my database. I have it so that this is working. The thing is when I click the edit page of a specific todo item, even when the owner of the todo is not null, the value of the dropdownlist gets set to "Select" because that is the default value of it. How do I code it so that if the Owner field is null, have it set to "Select" but if there is an owner in the field, I want the dropdownlist to be preselected as that owner? Controller: public ActionResult Edit(int? id, string owner) { if (Session["UserId"] != null) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Todo todo = db.Todoes.Find(id); if (todo == null) { return HttpNotFound(); } var options = new List(); options.Add(new Todo() { Status = "New Request", Text = "New Request" }); options.Add(new Todo() { Status = "Reviewed", Text = "Reviewed" }); options.Add(new Todo() { Status = "Started", Text = "Started" }); options.Add(new Todo() { Status = "In Progress", Text = "In Progress" }); options.Add(new Todo() { Status = "Completed", Text = "Completed" }); ViewBag.Status = options; List osrListItems = db.UserAccounts.Where(w => w.OSR != null).Select(osr => new SelectListItem { Value = osr.OSR, Text = osr.OSR }).Distinct().ToList(); ViewBag.OSRddl = new SelectList(osrListItems, "Value", "Text").Distinct(); //string x = ViewBag.OSRddl.Value; //if (todo.Owner != null) //{ //} return View(todo); } else { return RedirectToAction("Login", "Account"); } } // POST: Todoes/Edit/5 // To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see [HttpPost] [ValidateAntiForgeryToken] public ActionResult Edit([Bind(Include = "ID,Description,CreatedDate,Task,Status,FollowUp,Group,Owner")] string OSRddl, Todo todo) { if (Session["UserId"] != null) { //document.getElementById('FollowUp').value= if (ModelState.IsValid) { if (OSRddl != null) { todo.Owner = OSRddl; } db.Entry(todo).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(todo); } else { return RedirectToAction("Login", "Account"); } } View:


@Html.ValidationSummary(true, "", new { @class = "text-danger" }) @Html.HiddenFor(model => model.ID) [...]

Unable to increase the width of html drop-downs which are in Juqery data table


Dear All,

I have drop-downs in my Jquery Data table and I tried the below css , But I found no luck.

Can any one suggest me how what's wrong .

.txtparticipateidvalue select
{width:60px !important;


one-to-many relationship include and where


Hi Everyone,

var products = unitOfWork.Products.GetAll()
.Include(i => i.ProductDetails).Where(d=>d.ProductDetails.Any(i=>i.LanguageId==2)).ToList(); 

I have these two tables. I want to write the following sql code with entityframework. I tried the above code that doesn't work. 

FROM [dbo].[Products] P
LEFT OUTER JOIN [dbo].[ProductDetails] PD ON P.ProductId = PD.ProductId
WHERE PD.LanguageId=2
namespace MIS.WebUI.Entity
    public class Product
        public int ProductId { get; set; }
        public string ProductCode { get; set; }
        public string Image { get; set; }

        public ICollection ProductDetails { get; set; }
namespace MIS.WebUI.Entity
    public class ProductDetail
        public int ProductDetailId { get; set; }
        public int LanguageId { get; set; }
        public DateTime UpdateDate { get; set; }

        public string ProductName { get; set; }
        public string Description { get; set; }
        public string HtmlContent { get; set; }
        public double Price { get; set; }
        public int Currency { get; set; }
        public bool TaxIncluded { get; set; }

        public bool IsApproved { get; set; }
        public bool IsHome { get; set; }
        public bool IsFeatured { get; set; }

        public int? ProductId { get; set; }
        public Product Product { get; set; }


ASP.NET Windows authentication and ASP.NET Identity


I'm pretty new to ASP.NET MVC. I want to create Code First role based application with Windows authentication (Intranet users). I‘m using ASP.NET Identity framework and have created custom userStore and roleStore. I'm  stuck with how to configure that all new authenticated users will be added to userStore ?

Multiple Connection Strings in Core


Is there a way I can cycle through the connection strings in an appsettings.json file?

 "ConnectionStrings": {
    "DefaultConnection": "MyConnectionString",
   "ConnectionString2": "MyConnectionString"

tree table bind data from sql db without entity frame work



how can i create tree table bind from sql db into it but without using entity framework can anyone help me to do that?

Cannot insert duplicate key row in object 'dbo.TableName' with unique index



insert into TableName select Date, ServerName, DBName, DBNum, CheckType, Message from Master.dbo.ChildTableName where Date between dateadd(hour, 12, (Convert(DateTime, DateDiff(day, 0, getdate() - 1)))) and dateadd(hour, 8, (Convert(DateTime, DateDiff(day, 0, GetDate()))))

Error connecting to server ServerName. Exception calling "WriteToServer" with "1" argument(s): "Cannot insert duplicate key row in object 'dbo.TableName' with unique index 'IX_Daily_Checks_01'. The duplicate key value is (2018-04-18 18:35:34.7200000, ServerName, , Backup AG).

Any inputs on resolving above issue with out changing index functionality?

Loading MetaData from Partial Class in Aspnet Core


Hello everyone, I'm building a project in MVC template using AspNet Core.

I've used Entity Framework and I've scaffolded an existing DB. Now, I want to add some Data Annotations to some classes, but I don't wanna edit the class autogenerated by the scaffolding, so I've tried with the Metadata and the overriding of an existing method, the saveChanges().

Users.cs autogenerated by Scaffolding
public partial class Users
    public int UserId { get; set; }
    // If I have [MaxLength(5, ErrorMessage = "Too short")] here, it works
    public string Email { get; set; }

UsersMetadata.cs (also tried Users.Metadata.cs or else, nothing changed)
public partial class Users { }

public class UsersModelMetaData
    [MaxLength(5, ErrorMessage = "Too short")]
    public string Email { get; set; }

MyContext : DbContext Class
public override int SaveChanges()
    var entities = from e in ChangeTracker.Entries()
        where e.State == EntityState.Added
        || e.State == EntityState.Modified
        select e.Entity;
    foreach (var entity in entities)
        var validationContext = new ValidationContext(entity);
        Validator.ValidateObject(entity, validationContext, validateAllProperties: true);

    return base.SaveChanges();

So, even if this seems to be the correct solution (i've search all morning), it doesn't work: the problem seems to be that the Data Annotation inside UsersModelMetaData aren't read, because if I put the Data Annotation directly in Users.cs file, method saveChanges() will throw an exception.
Notice that I had to override the saveChanges() method because, as I understood, in AspNet Core there is no DbEntityValidationException, so in this way I can detect ValidationException.

I did found this solution -> <- but it's based on AspNet, and using AspNet Core I cannot use AssociatedMetadataTypeTypeDescriptionProvider.

Any idea how I could resolve this?

enable disable textbox based on selection - jquery


im trying to enable disable textboxes based on drop down selection , but its NOT working , and im NOT getting any errors in chrome browser code debugger , any suggestion , below is my code