Subscribe: Web Forms
http://forums.asp.net/rss.aspx?ForumID=18
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
connection  data  function  new  public shared  public  runat server  runat  server  set  string  system  text  textbox 
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: Web Forms

All Forums



All Forums



Last Build Date: Wed, 24 May 2017 16:32:32 -0700

 



ASP.NET CORE Angular2 Routing

2017-05-24T09:17:46.273-07:00

Hi Guys,

I want build same web application with Angular 2 and ASP.NET MVC Core.
I have one problem, I use template ASP.NET Core Angular 2 Starter Application (.NET Core) when template has been generated I can see in ClientApp\App folder that Angular Template is html.

(image)

I don't want use HTML I want use CSHTML instead.

Could you please help me how can I use cshtml as template in Angular 2?
Also I tired in template set controler/action as url and I get error

(image)




Displaying records in view using for loop as @item.fieldname

2017-05-24T09:56:00.737-07:00

public class testviewmodelClass
{
    public int customerscount { get; set; }
    public int ordercount { get; set; }
    public List PrdtName { get; set; }
    public int ProductCount { get; set; }
    public  List OrderList { get; set; }}
public string productname  { get; set; }}
public string orderno  { get; set; }}
public string shippingaddress  { get; set; }}
public datetime orderdt  { get; set; }}
 
Displayviewmodel db = new Displayviewmodel();
IQueryable productDetails = db.Products.GroupBy(n => n.Product_Name).Select(n => new { PrdtName = n.Key, ProductCount = n.Count() });

IQueryable OrderDetails = from c in db.Orders
                                                 join d in db.Products on c.ProductId equals d.ProductId
                                                 join p in db.OrderAdd on c.OrderId equals p.OrderId
                                                 
                                                 select new
                                                 {
                                                     Orderdt = c.Orderdt == null ? DateTime.Now : c.Orderdt ,
                                                  
                                                     shippingaddress = p.shippingaddress ,
                                                     ProductName= d.ProductName

                                                 };

Displatviewmodel  vm = new DisplayviewmodelClass()
{
    customerscount = db.Customers.Count(),
    ordercount = db.Orders.Count(),
    PrdtName = prodectDetails.ToList(),
OrderList=OrderDetails.ToList()
};

i have the above viewModel and code in controller

i need to display the result in table format 

  @foreach (var item in Model.PrdtName)
                                                                    {
                                                                    
                                                                        @item 
                                                                        @item

                                                                    
                                                                    }

but in view i am not getting as

@item.ProductName
@item.ProductCount

not displayed in item

same for orderList

in browser its displayed as 

{ PrdtName= Book1, ProductCount = 1 }
{ PrdtName= Book21, ProductCount = 2 }
{ PrdtName= Book51, ProductCount = 2 }
{ PrdtName= Book2, ProductCount = 1 }
{ PrdtName= Book5, ProductCount = 1 }
{ PrdtName= Book8, ProductCount= 3 }
{ PrdtName= medr, ProductCount= 5 }
{ PrdtName= mnmmmm, ProductCount= 1 }




Converting a Delphi 6 Function to c#

2017-05-17T13:45:18.657-07:00

Hi guys. I have this simple function in Delphi

function Round45 (Value : Real; RPower : Integer) : Real;
begin
  Result := Trunc (Value * Power (10, RPower) + 0.5)/Power (10, RPower);
end;

It's purpose was to provide a result in the range from 0 to 100.

I am attempting to convert that function to c#

I have tried using Math.Round but that produces a double - I require an integer from 0 to 100.

Any help would be appreciated.




Can a Function that is in a controller that returns a value be called from the _Layout.cshtml form?

2017-05-24T21:13:29.877-07:00

Hi All,

Can  mvc call a function that is in a controller and that returns a value be called from the _layout.cshtml.

For example where the user access the page I want to know if they are an application Admin. So I capture their user ID from their computer and I run it against a database.

that database tells me of they are an admin or not.

So in this case I want to allows some actionlink to be visible if they are admins.

I am not seeing anything that I understand on the world wide web that says this is possible . They show that you can make buttons that when clicked they will run a function but nothing that will run when the page is load allowing me to call a function and used it return value in a if  statement on the layout page.

IF any one has any ideas I would appreciate as I don't want to have to build this logic for every page.. it would be nice if it was part of the layout page.

Thanks




Who downloads the CDN? IIS or Browser?

2017-05-23T23:34:30.85-07:00

Hi,

Please enlighten me, recently i use CDN for my JQuery and other JS and CSS libraries, but the problem is the Server somehow blocks the CDN path.

Can someone explain to me the technical process on how CDN works in IIS?

I was thinking that the client browser is the one that downloads the CDN file, but why do we need to unblock the CDN path in the server?

Thanks




Getting the Instance of Interface in the Runtime

2017-05-24T14:03:51.247-07:00

Hi There;

I am not sure whether here is right place to ask.

My problem is I want to get the concrete implementation of instance in runtime.  I have some web requests and I try to get proper command for them. Here is the code:

Here is the information in advance: 

    public interface IPageNavigator
    {
        void NavigateTo(PageDirectory page);
    }


Here is the concrete implementation of IPageNavigator

public class PageNavigator : IPageNavigator
    {
        public void NavigateTo(PageDirectory page)
        {
            switch (page)
            {
                case PageDirectory.Home:
                    HttpContext.Current.Server.Transfer("~/views/Home/Index.aspx");
                    break;
                case PageDirectory.ProductDetail:
                    HttpContext.Current
                    .Server.Transfer("~/views/Product/ProductDetail.aspx");
                    break;
                case PageDirectory.CategoryProducts:
                    HttpContext.Current
                    .Server.Transfer("~/views/Product/CategoryProducts.aspx");
                    break;
                case PageDirectory.MissingPage:
                    HttpContext.Current.Server.Transfer("~/views/Shared/404.aspx");
                    break;
            }
        }
    }

Here is the another construction in my code. As you can see, it gets IPageNavigator as a constructor parameter :

  public class Display404PageCommand : IWebCommand
    {
        private IPageNavigator _navigator;
        public Display404PageCommand(IPageNavigator navigator)
        {
            _navigator = navigator;
        }
        public bool CanHandle(WebRequest webRequest)
        {
            return true;
        }
        public void Process(WebRequest webRequest)
        {
            _navigator.NavigateTo(PageDirectory.MissingPage);
        }
    }

Here is the place that I get error: 

        public IWebCommand GetCommandFor(WebRequest webRequest)
        {
            return _webCommands.FirstOrDefault(wc => wc.CanHandle(webRequest)) ?? new Display404PageCommand( );
        }

As you can see, inside the Display404PageCommand class, I need to give a class that implements IPageNavigator.  It is PageNavigator, but I want a structure that gets the instance of IPageNavigator.  I am aware of Ninject, but it is not solution, because it is a constructor based ioc. I need resolving interface by function ,that is like that: 

SomeClass.GetInstance(IPageNavigator);

 How can I do it? thanks in advance.




Updating Claims Identity Value without logging out and back in

2017-05-24T17:32:43.94-07:00

When I update a Claims identity value, it updates in the database, but in order to show the new value in the application, I have to log out and log back in. I know it’s a cookie issue, but I need it to show the new value by doing a page refresh and not by logging out and back in. 

IdentityExtensions.cs

public static string GetAnnounceCount(this IIdentity identity)
{
var claim = ((ClaimsIdentity)identity).FindFirst("AnnounceCount");
// Test for null to avoid issues during local testing
return (claim != null) ? claim.Value : string.Empty;

}


I'm currently access the value from the database for the logged in user by using @User.Identity.GetAnnounceCount()


The value resets to 0 in the database with this line from the code below

user.AnnounceCount = 0


 , but the application won’t reflect the reset to 0 until I log out and log back in

public ActionResult AnnouncementList(Announcement announcement)
{

var announcementInDb = _context.Announcement.SingleOrDefault(a => a.Id == announcement.Id);


var users = _context.Set().ToList();
string currentUserId = User.Identity.GetUserId();


var store = new UserStore(_context);
var manager = new ApplicationUserManager(store);
var user = manager.Users.FirstOrDefault(u => u.Id == currentUserId);

user.AnnounceCount = 0;

manager.Update(user);


// Save the new value to the database
_context.SaveChanges();


return View("AnnouncementList");

}






Make a Decimal field optional, but never null

2017-05-22T23:16:41.12-07:00

I have an existing app that displays information about the monuments at National Parks. When adding a new entry to the dB, the app requires the user to supply the GPS Coordinates of the monument and where you can park. When the monument is visible from the road, I want to default the parking coordinates to the monument coordinates so that the user does not have to enter the same, or nearly the same, info twice. It is kind of useless information. Simply leaving the field blank is OK, but then I get error in other code that will not handle nulls. Model: namespace CWBFM.Models { public class Monument { ---- [DisplayName("Monument latitude")] [Required(ErrorMessage = "Enter the latitude of the monument.")] [Range(25.00, 47.50, ErrorMessage = "Latitude must be between 25.00 and 47.5 degrees north.")] public decimal MonumentLocationLat { get; set; } [DisplayName("Monument longitude")] [Required(ErrorMessage = "Enter the longitude of the monument.")] [Range(-111.55, -75.50, ErrorMessage = "Longitude must be between -75.50 and -111.55 degrees west.")] public decimal MonumentLocationLong { get; set; } [DisplayName("Visible from the road")] public bool MonumentVisibleFromRD { get; set; } ----- / -----------------------------------Parking Information --------------------------------------------------- // a decimal field is always required. Decimal? makes the field 'NULLable, so will make this optional. Db is defined as NOT NULL [DisplayName("Parking latitude")] [Range(25.00, 47.50, ErrorMessage = "Latitude must be between 25.00 and 47.5 degrees north.")] public Decimal MonumentParkingLat { get; set; } [DisplayName("Parking longitude")] [Range(-111.55, -75.50, ErrorMessage = "Longitude must be between -75.50 and -111.55 degrees west.")] public Decimal MonumentParkingLong { get; set; } I tried changing parkingLat/Long to Public Decimal? (allow null) but ran into an issue that after I updated the dB and tried to display the new entry got into trouble with the code that converts the degrees decimal to degrees minutes decimal. View: ----
@Html.TextBoxFor(model => model.MonumentParkingLat) @Html.ValidationMessageFor(model => model.MonumentParkingLat)
Enter the longitude of where to park
Enter the longitude of where to park in decimal degrees in decimal degrees; there is no need to enter the “W”, but the number must be negative, example -88.346
The longitude must be between -111.55 and -75.50. See @Html.ActionLink("How to Obtain Latitude and Longitude", "GetLatitudeLongitude", "Home", null, new { target = "_blank" }) for help with obtaining the coordinates or converting the coordinates to decimal degrees.
@Html.TextBoxFor(model => model.MonumentParkingLong) @Html.ValidationMessageFor(model => model.MonumentParkingLong)
----- My controller when I had public Decimal? MonumentParkingLat { get; set; } // POST: /Monument/Create [HttpPost] [Authorize] public ActionResult MonumentCreate(Monument monument) { ----- if (monument.MonumentParkingLat == null) { monument.MonumentParkingLat = monument.MonumentLocationLat; mon[...]



Simple CRUD app with filters and sorting

2017-05-23T21:57:25.77-07:00

Hello all, I am working on creating a CRUD app which will have filters and sorting enable. I currently have GridView which is retrieving data from a view in oracle database. I also have 3 dropdownlist boxes which are retrieving distinct values from database. I am having issues when passing the values to filter the data in GridView. I am using Configure Data Source window to add a WHERE clause but I keep receiving an error. When I specify a custom SQL statement it works but I cannot add where clause to pass the parameters. CODE: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Comments.aspx.cs" Inherits="ChngMgmt_Comments_and_Legends.Comments" %>
       

Year Month:       

Section Name:    

Tab Name:          



[...]



Installed nuget package BotDetect but tagprefix botdetect not recognized

2017-05-24T20:22:58.617-07:00

I'm trying to add a captcha to the contact form on my webform.  Installed the nugget package Captcha and BotDetect now shows up on my list of references as expected but when I put in the aspx code...


...visual studio underlines botdetect and indicates "unrecognized tagprefix or device filter 'botdetect' .

Would someone kindly tell me what I need to do to get the tagprefix recognized or what I'm doing wrong?  Thanks tonnes for any help, Roscoe




Multiple placeholders using different CSS classes

2017-05-19T20:37:26.797-07:00

I’m trying to use multiple placeholders with different CSS classes and am having trouble understanding how it works. I have a MainContent placeholder that is formatted correctly and I’m trying to add a second ContentPlaceholder but it doesn’t apply the rules from the classes in the CSS.

In my Site.master I have:

        

Product place holder

and in my content page Products.axpx:

<%@ Page Title="Products" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="Products.aspx.cs" Inherits="Products" %>



   

    (image) 

    

Product 1

Product 2

Product 3

Product 4

Product 5

and my Site.css:

.productCat{
    background-color:aquamarine;
}

.product-category {
    display: flex;
    flex-flow: row wrap;
    height: 100%;
    width: 100%;
}

.product-category-odd {
 
    justify-content:flex-start;
}

.product-category-even {
    flex:1;
    justify-content:flex-end;
}

The .productCat class sets the background-color correctly but the other classes do not apply the formatting.




.Net Core Scaffolding - Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

2017-05-19T13:36:29.38-07:00

Can anyone suggest why I get the following when trying to reverse engineer the models for a .Net Core Web API?  The Scaffolding text does not throw an error if the database is small. Scaffold-DbContext "Server=(localdb)\mssqllocaldb;Database={database name};Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception: The wait operation timed out    --- End of inner exception stack trace ---    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)    at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)    at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()    at System.Data.SqlClient.SqlDataReader.get_MetaData()    at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)    at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)    at Microsoft.EntityFrameworkCore.Scaffolding.Internal.SqlServerDatabaseModelFactory.GetColumns()    at Microsoft.EntityFrameworkCore.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(DbConnection connection, TableSelectionSet tableSelectionSet)    at Microsoft.EntityFrameworkCore.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(String connectionString, TableSelectionSet tableSelectionSet)    at Microsoft.EntityFrameworkCore.Scaffolding.RelationalScaffoldingModelFactory.Create(String connectionString, TableSelectionSet tableSelectionSet)    at Microsoft.EntityFrameworkCore.Scaffolding.Internal.SqlServerScaffoldingModelFactory.Create(String connectionString, TableSelectionSet tableSelectionSet)    at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineeringGenerator.GetMetadataModel(ReverseEngineeringConfiguration configuration)    at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineeringGenerator.GenerateAsync(ReverseEngineeringConfiguration configuration, CancellationToken cancellationToken)    at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContextAsync(String provider, String connectionString, String outputDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, CancellationToken cancellationToken)    at Microsoft.EntityFrameworkCore.Design.OperationExecutor.d__22.MoveNext()    at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source, Int32& length)    at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)    at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)    at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass4_0`1.b__0()    at Microsoft.EntityFramewo[...]



A Function inside App_Code Class is not callable

2017-05-24T15:18:09.877-07:00

I created a class "TDClass.vb" inside App_Code folder. The "TDClass.vb" class is as following Imports Microsoft.VisualBasic Imports System.Data Imports System.Data.SqlClient Imports System.Configuration Imports System.Diagnostics Imports System.Drawing.Printing Imports System.Windows.Forms Imports System.Collections.Generic Imports Microsoft.Office.Interop Imports System.IO.File Imports Neodynamic.SDK.Web Public Class TDClass Public Shared UserName As String Public Shared UserIndx As Integer Public Shared PassCode As String Public Shared UserUnitIndx As Integer Public Shared SelectedOffice As String Public Shared ShownOffices As New Stack Public Shared ReportingToStack As New Stack Public Shared HeadOffices As New Stack Public Shared PendingCommentsRemarkerHeadsStack As New Stack Public Shared queryString As String Public Shared PreviousFormPath As String Public Shared TheSameLevelUnits As SqlDataReader Public Shared LIDCount As Integer Public Shared Initiator As Integer Public Shared DataEntryRight As Integer Public Shared DataEntryRightB As Integer I added the following function "GetExternalParameters" inside the "TDClass.vb" class: Public Shared Function GetExternalParameters(ByVal UnitIndex As Long, ByVal Purpose As String) As String Dim querystring As String Dim EntityName As String Dim EntityTitle As String Dim EntityCPR As String GetExternalParameters = "" Dim conString = ConfigurationManager.ConnectionStrings("TrackingConnectionString").ConnectionString Using connection As New SqlConnection(conString) connection.Open() If Purpose = "entity" Then querystring = "SELECT Entity FROM ExternalEntities WHERE (Indx=@Ix)" Dim ExtractEntityName As New SqlCommand(querystring, connection) ExtractEntityName.Parameters.Add("@Ix", SqlDbType.Int) ExtractEntityName.Parameters("@Ix").Value = UnitIndex If IsDBNull(ExtractEntityName.ExecuteScalar()) = False Then EntityName = ExtractEntityName.ExecuteScalar() GetExternalParameters = EntityName End If ElseIf Purpose = "title" Then querystring = "SELECT Title FROM ExternalEntities WHERE (Indx=@Ix)" Dim ExtractTitle As New SqlCommand(querystring, connection) ExtractTitle.Parameters.Add("@Ix", SqlDbType.Int) ExtractTitle.Parameters("@Ix").Value = UnitIndex If IsDBNull(ExtractTitle.ExecuteScalar()) = False Then EntityTitle = ExtractTitle.ExecuteScalar() GetExternalParameters = EntityTitle End If ElseIf Purpose = "cpr" Then querystring = "SELECT CPR FROM ExternalEntities WHERE (Indx=@Ix)" Dim ExtractCPR As New SqlCommand(querystring, connection) ExtractCPR.Parameters.Add("@Ix", SqlDbType.Int) ExtractCPR.Parameters("@Ix").Value = UnitIndex If IsDBNull(ExtractCPR.ExecuteScalar()) = False Then EntityCPR = ExtractCPR.ExecuteScalar() GetExternalParameters = EntityCPR End If End If End Using End Function I have form "ShowPostingDetails_ExFrom.aspx". It contains a textbox "FormExternalEntityNameTxtBox". I call the "GetExternalParameters" function from the form [...]



Saving data from textbox into ms access database

2017-05-24T19:50:16.803-07:00

I am doing a registration form and I am trying to save them into an ms access database.

In my form load , my code is 

        MsgBox("A connection to the database is open")
        sql = "SELECT * FROM Client_Bank"
        'dt.Clear()
        da = New OleDb.OleDbDataAdapter(sql, con)
        da.Fill(ds, "Register")
        maxRows = ds.Tables("Register").Rows.Count
        row = 0
        UserNameTextBox.Text = ds.Tables("Register").Rows(row).Item(1)
        SurnameTextBox.Text = ds.Tables("Register").Rows(row).Item(2)
        FirstNameTextBox.Text = ds.Tables("Register").Rows(row).Item(3)
        GenderTextBox.Text = ds.Tables("Register").Rows(row).Item(4)
        AddressTextBox.Text = ds.Tables("Register").Rows(row).Item(5)
        EmailTextBox.Text = ds.Tables("Register").Rows(row).Item(6)
        PasswordTextBox.Text = ds.Tables("Register").Rows(row).Item(7)

In my save button my code is

        If row <> -1 Then
            Dim cb As New OleDb.OleDbCommandBuilder(da)
            Dim dsNewRow As DataRow
            dsNewRow = ds.Tables("Register").NewRow()
            dsNewRow.Item("ID") = CStr(maxRows + 1)
            dsNewRow.Item("UserName") = UserNameTextBox.Text
            dsNewRow.Item("SurName") = SurnameTextBox.Text
            dsNewRow.Item("FirstName") = FirstNameTextBox.Text
            dsNewRow.Item("Gender") = GenderTextBox.Text
            dsNewRow.Item("Address") = AddressTextBox.Text
            dsNewRow.Item("Email") = EmailTextBox.Text
            dsNewRow.Item("Password") = PasswordTextBox.Text

           ds.Tables("Register").Rows.Add(dsNewRow)
            da.Update(ds, "Register")
            MsgBox("New record added to the database")
            row = maxRows + 1
        End If
        btnAdd.Enabled = True

But I keep getting this error:

An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll

Additional information: Syntax error in INSERT INTO statement.

Any help please ? 




SignalR version 1.2.2 client side method not being called, nor is console logging being made

2017-05-24T16:06:40.07-07:00

I am using this tutorial: https://docs.microsoft.com/en-us/aspnet/signalr/overview/older-versions/tutorial-server-broadcast-with-aspnet-signalr   to broadcast a message from Conext stored in singleton.  I have a few issues.  First, there doesn't seem to be any issues from assigning the hub and making a connection from the client side. This is my code: $(function () { var transactionHub = $.connection.TransactPtHub; // the generated client-side hub proxy transactionHub.client.broadcastDmrUpdate = function (test) { alert("Yo-Yo Ma!!" + test); }; console.log('test'); $.connection.hub.logging = true; $.connection.hub.start() .done(function () { console.log('Now connected, connection ID=' + $.connection.hub.id); }) .fail(function () { console.log('Could not Connect!'); }); if ($.connection.hub.state === $.signalR.connectionState.disconnected) { alert("connected"); } else { alert("not connected"); } }); My alert, "connected" does display on page load. The function in this part of the code, "transactionHub.client.broadcastDmrUpdate = function (test) {..." never gets called from the server side. This is my singleton: public class TransactPtSingleton { private readonly static Lazy _instance = new Lazy(() => new TransactPtSingleton(GlobalHost.ConnectionManager.GetHubContext().Clients)); private TransactPtSingleton(IHubConnectionContext clients) { Clients = clients; } private IHubConnectionContext Clients { get; set; } public static TransactPtSingleton Instance { get { return _instance.Value; } } public void BroadcastDmrUpdate(string dmr) { Clients.All.broadcastDmrUpdate(dmr); } } and this is my hub, [HubName("TransactPtHub")] public class TransactPtHub : Hub { public void UpdateDailyTransactionTable() { } } So, I don't get a call back to the client function on broadcast, and even though I set my logging to true, I am not seeing any logs inside of my browser console.  Where do I begin to troubleshoot? Or what am I doing wrong? Thank you. UPDATE: I misread my own diagnostics. if ($.connection.hub.state === $.signalR.connectionState.disconnected) { is triggering, so the connection is not starting for some reason. Also, the .done and .fail never get entered, and I never get any console messages. Update 2: Combing through the SignalR it seems to have something to do with, // Check to see if start is being called prior to page load // If waitForPageLoad is true we then want to re-direct function call to the window load event if (!_pageLoaded && config.waitForPageLoad === true) { connection._.deferredStartHandler = function () { connection.start(options, callback); }; _pageWindow.bind("load", connection._.deferredStartHandler); return deferred.promise(); } as on return deferred.promise() it leaves the SignalR  and comes back to the calling script in UI. [...]



How to populate datatable

2017-05-24T18:08:13.92-07:00

How to populate and display a datatable

protected void btnSearchNames_Click(object sender, EventArgs e)
        {
            string text = "";
            string textboxValue = "";

            text = ddlSearchBy.SelectedValue;
            textboxValue = txtSearchByName.Text.ToString();

            using (SqlConnection cn = new SqlConnection(Data.DBConnectionString))   
            {
                using(SqlCommand cmd = new SqlCommand("dbo.SearchForStudent", cn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    if ((text != null) && (textboxValue != null) && (text == "LName"))
                    {
                        lastName = text;
                        cmd.Parameters.AddWithValue("@lastName", lastName);     // variables declared at the top
                        // dataTable dt = new datatable();
                        // what goes on this line???
                    }
                }
            }      
        }




Browser does not display correct language after copy pasting text into view

2017-05-24T15:17:41.343-07:00

in my aps.net app I pasted in some example code from bootstrap. then i changed some text which uses letters that are not in the english alphabet. But the letters aren't displayed correctly on this page. It works on all my other pages. I tried to change the language spec in my html like this:


but that does not solve my issue.

any ideas?

edit: on further inspection it seems that it has something to do with the global language setting in asp.net core, which you can set. the only strange thing for me is why it suddenly changed.




ScriptManager.RegisterClientScriptBlock is not working in a RegisterPostBackControl of gridview in update panel

2017-05-24T18:37:22.92-07:00

Hi, 

In the web page, there is a file Upload control and grid view. The file uploaded will be shown as a row in the grid view. One of the columns has a file content and allowed to download it [image control]. I have made this control as RegisterPostBackControl. 

When I click on download I should disable the file upload control and other two client side [html] controls. If I am trying to call a javascript from this registered post back control it is not executing the javascript. Any idea?

protected void gvInprog_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            ImageButton Data = (ImageButton)e.Row.FindControl("btnDataInprogress");
            ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
            scriptManager.RegisterPostBackControl(Data);
        }
    }
 protected void btnDataInprogress_Click(Object sender, EventArgs e)
    {
        try
        {
            ScriptManager.RegisterClientScriptBlock(panelInprogress,panelInprogress.GetType(), "myScript", "javascript:disableUploadButtons();", true);
            GridViewRow clickedRow = ((ImageButton)sender).NamingContainer as GridViewRow;
            int TransactionId = Convert.ToInt32(clickedRow.Cells[0].Text);
            bool IsTransactionId = TransactionId > 0 ? true : false;
            if (IsTransactionId)
            {
                DataInfo.GetData(TransactionId, Response);              
            }
           ScriptManager.RegisterClientScriptBlock(panelInprogress,panelInprogress.GetType(), "myScript", "javascript:enableUploadButtons();", true);
        }

 catch (Exception ex)
        {
            ScriptManager.RegisterClientScriptBlock(panelInprogress,panelInprogress.GetType(), "myScript", "javascript:enableUploadButtons();", true);
        }
    }

JavaScript:
function disableUploadButtons() { btnupload.disabled = true; document.getElementById('btnUpload').disabled = true; document.getElementById('btnClear').disabled = true; } function enableUploadButtons() { btnupload.disabled = false; document.getElementById('btnUpload').disabled = false; document.getElementById('btnClear').disabled = false; }




avoid page load when click on dropdownlist while inserting data in form

2017-05-22T07:51:42.207-07:00

i have panel in asp.net website   this is design part

Please Fill This Form TO Participate(Singing Registration)

select Solo singing Duet singing Group singing



Get Docker container ID in code

2017-05-24T14:34:44.47-07:00

I have the need to log the container ID my app is running in. Is there a way to get this via C#?