I've a textarea and a relative regularExpressionValidator. How can I validate the innerText property of my textArea instead of innerHtml? Or there's a way to set the value to validate to regularExpressionValidator?

Thanks!!!

We are using the New Relic .NET agent (v3.2.6.0) in an ASP.NET (v4.5) web site, and we want to exclude a certain directory, so the agent will not inject JS code into the HTML pages in that directory. The documentation states:

requestPathsExcluded

Use this sub-element to prevent the Browser agent from being injected in specific pages. The element is used as follows: <requestPathsExcluded> <path regex="url-regex-1"/> <path regex="url-regex-2"/> ... <path regex="url-regex-n"/> </requestPathsExcluded>

The agent will not inject the Browser agent into pages whose URL matches one of the specified regular experssions. The regular expression should follow Microsoft guidelines for the Regex class.

However, the documentation isn't very specific and doesn't give any concrete examples, and we weren't able to get it to work with a regex that matches the entire url: (.*)directoryName/(.*). Can we just put the name of the directory instead of a regex - directoryName/? Do we need to add a "*" to filter all child urls as well?

I don't know why but whenever the page gets refreshed ( when I select a dropdown, when I click on save button which shows error that some fields need to be filled before submitting the form... in these situation the page gets reloaded)

And whenever page gets refreshed My TinyMCE turns HTML controls visible, and on second refresh it turns those html to garbage character..

for e.g. **after first refresh**
Hi This is john<sup>123</sup>
**after second refresh**
Hi This is john&lt;sup&gt;123&lt;/sup&gt;

Any help ?

Is there a way that I can do partial refresh so that TinyMCE doesn't gets refreshed.

Im trying to loop through a collection and create checkboxes for each item in the collection. I check if a bool is true and want that checkbox to be checked. But I cant seem to get this to work. What am I missing here?

var checkboxList = new CheckBoxList();

foreach (var answer in question.Answers)
{
    if (answer.CorrectAnswer)
    {
        var cbItemOrd = new CheckBox
        {
            Checked = true, 
            Text = answer.AnswerText + " Correct Answer"
        };
        checkboxList.Items.Add( cbItemOrd.Text );
        cbItemOrd.Checked = true;
    }
    else
    {
        checkboxList.Items.Add(answer.AnswerText);
    }

}
div.Controls.Add(checkboxList);

I get the "correct answer" text out on the correct field so the loop works. If I need to use "FindControl" or something, how do I do that with programmatically created objects?

Thanks alot!

My issue is that I am being held up from creating a new database table from an existing project due to an object either not existing or being invalid for this operation. I have made the effort to search all the migrations for missing values, and have not found why the object is missing.

As well, I have tried creating a fresh migration, but with no success. Any and all help is appreciated.

I am using SQL server 2012 and ASP.net in VS2015.

The Nu-get information is as follows:

  System.Data.SqlClient.SqlException (0x80131904): The object 'dbo.FOO' does not exist or is invalid for this operation.



   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.SqlInternalConnection.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.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<NonQuery>b__0(DbCommand t, DbCommandInterceptionContext`1 c)
   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext)
   at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteNonQuery()
   at System.Data.Entity.Migrations.DbMigrator.ExecuteSql(MigrationStatement migrationStatement, DbConnection connection, DbTransaction transaction, DbInterceptionContext interceptionContext)
   at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ExecuteSql(MigrationStatement migrationStatement, DbConnection connection, DbTransaction transaction, DbInterceptionContext interceptionContext)
   at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection, DbTransaction transaction, DbInterceptionContext interceptionContext)
   at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsWithinTransaction(IEnumerable`1 migrationStatements, DbTransaction transaction, DbInterceptionContext interceptionContext)
   at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsWithinNewTransaction(IEnumerable`1 migrationStatements, DbConnection connection, DbInterceptionContext interceptionContext)
   at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection, DbInterceptionContext interceptionContext)
   at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection)
   at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClass30.<ExecuteStatements>b__2e()
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation)
   at System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable`1 migrationStatements, DbTransaction existingTransaction)
   at System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable`1 migrationStatements)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.ExecuteStatements(IEnumerable`1 migrationStatements)
   at System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, VersionedModel targetModel, IEnumerable`1 operations, IEnumerable`1 systemOperations, Boolean downgrading, Boolean auto)
   at System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
   at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
   at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
   at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
   at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
   at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClassc.<Update>b__b()
   at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
   at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
   at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run()
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
   at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
   at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
ClientConnectionId:4207860a-9d88-4ce7-96f5-cbb0d85cec14
Error Number:8197,State:4,Class:16
The object 'dbo.Institutions' does not exist or is invalid for this operation.
PM> 

Plain and simple, what's the proper way to do this without running into issues?

  • I have a a RadGrid, which will be populated with data at some point during the page's life-cycle. Likely after a button click on the page.
  • I have a RadWindowManager defining my windows' attributes.
  • I want to create and open a window based on data from the table.

My initial thought was doing

<ClientSettings EnablePostBackOnRowClick="true">
    <Selecting AllowRowSelect="true" />
    <ClientEvents OnRowClick="OnRowClick" />
</ClientSettings>

for my RadGrid settings. But I'm lost on how to get the client to open a new window (Telerik states that RadWindow and RadWindowManager are client-side controls), while also getting the server-side to access my business logic for populating the window with data - also selecting the right type of UserControl to stick in the window.

JavaScript inside my RadScriptBlock:

var windowManager = $find("<%= WindowManager_PopIns.ClientID %>");
function OnRowClick(sender, eventArgs) {
  if(windowManager != null) {
    var grid = sender;
    var MasterTable = grid.get_masterTableView();
    var row = MasterTable.get_dataItems()[eventARgs.get_itemIndexHierarchical()];
    var cell = MasterTable.getCellByColumnUniqueName(row, "ID");

    if (cell != null) {
      var windowURL = ""; // ??? I want the URL to be a UserControl with a query string maybe?
      var windowID = cell; // I think this should get the ID as the window's name
      var newWindow = windowManager.open(windowURL , windowID);
      newWindow.set_title("SomeName" + " " + "SomeIdentifier");
    }
  }
}

This is what I currently have. My main issue, like stated, is that I don't know how to populate this window after creation or opening.
Bonus: How can I do this so that the page with this manager and graph can be used as a sort of master page, allowing "child" pages that would define what goes in the title, what data/columns go in the grid, and what to load in the actual window?

I have a an Inspector ID in a div I am trying to access so I can get the corresponding UserName out of an IEnumerable called inspectors. There's two ways I can see doing this, either I can set Model.InspectorId to the value in the div or I can reference $("#InspectorDropDown").val() in the query. Neither of these are working because they blend JavaScript, HTML and Razor Syntax in a messy way. Is there are simple solution for this problem?

Here is the dropdown which populates the div with the correct ID

@Html.DropDownListFor(x => x.Inspector, inspectors, "--Select--", new { @id = "InspectorDropDown", @class = "form-control" })

Attempt 1:

var wrongway = $("#InspectorDropDown").val()

$.post('@Url.Action("SetInspectionDetails", "Inspections")', {

                    inspector: "@inspectors.Where(x => x.Value == wrongway).FirstOrDefault().Text",



                }).done(function(response){

This gives an error because in the context of the razor syntax the JavaScript variable is inaccessible.

Attempt 2:

@Model.InspectorId = $("#InspectorDropDown").val()

This also gives an error because it mixes JavaScript and Razor Syntax.

Is there a simpler way to do this with either JavaScript or Razor Syntax?

I'm current facing a strange issue that everytime i want to update my table value field from reserved to cancelled.

every time i click the button it din't pop any error but when i went to my ms-access to check it never change...

My Method:

    public static void CancelClasses(int rid, int mid)
    {
        OleDbConnection myconnection = GetConnection();
        string mysql = "UPDATE ClassesReservation SET Status = 'cancelled' WHERE ReservationID= "+rid+" AND MID="+mid+";";
        OleDbCommand mycmd = new OleDbCommand(mysql, myconnection);
        try
        {
            myconnection.Open();
            mycmd.ExecuteNonQuery();
        }
        catch
        {
            throw;
        }
        finally
        {
            myconnection.Close();
        }
    }

Button Function:

    protected void CancelWS_Click(object sender, EventArgs e)
    {
        if (ListBox3.SelectedIndex < 0)
        {
            Label2.Text = "Invalid Submit! Please select an Class or Workshop";
        }
        else
        {
            int reid = int.Parse(ListBox3.SelectedValue);
            int MID = Convert.ToInt32(Session["memberid"]);

            DBconn.CancelClasses(reid, MID);

        }
    }

Basically i have created a mvc application that will be performing CRUD operations on the database data using entity framework generated from database edmx.So in this after adding EDM and configuring database settings i've added a controller named CRUD with scaffolding enabled to read/write action views and attached model and DB conttext to it.Now everything works as desired upto the point of adding new employee ie Create.The problem comes when i run the index page of crud controller and in which when i press the actionlink edit or delete for any specific employee data it doesn't find that Edit and Delete cshtml pages at all and instead shows the error 404 resource not found.Please help me figure out what's wrong,i'm posting my whole code below:

    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.Entity;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;

    namespace MvcApplication2.Controllers
    {
        public class CRUDController : Controller
        {
            private TestDBEntities2 db = new TestDBEntities2();

            //
            // GET: /CRUD/

            public ActionResult Index()
            {
                return View(db.Emps.ToList());
            }

            //
            // GET: /CRUD/Details/5

            public ActionResult Details(int id = 0)
            {
                Emp emp = db.Emps.Find(id);
                if (emp == null)
                {
                    return HttpNotFound();
                }
                return View(emp);
            }

            //
            // GET: /CRUD/Create

            public ActionResult Create()
            {
                return View();
            }

            //
            // POST: /CRUD/Create

            [HttpPost]
            [ValidateAntiForgeryToken]
            public ActionResult Create(Emp emp)
            {
                if (ModelState.IsValid)
                {
                    db.Emps.Add(emp);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }

                return View(emp);
            }

            //
            // GET: /CRUD/Edit/5

            public ActionResult Edit(int id = 0)
            {
                Emp emp = db.Emps.Find(id);
                if (emp == null)
                {
                    return HttpNotFound();
                }
                return View(emp);
            }

            //
            // POST: /CRUD/Edit/5

            [HttpPost]
            [ValidateAntiForgeryToken]
            public ActionResult Edit(Emp emp)
            {
                if (ModelState.IsValid)
                {
                    db.Entry(emp).State = EntityState.Modified;
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
                return View(emp);
            }

            //
            // GET: /CRUD/Delete/5

            public ActionResult Delete(int id = 0)
            {
                Emp emp = db.Emps.Find(id);
                if (emp == null)
                {
                    return HttpNotFound();
                }
                return View(emp);
            }

            //
            // POST: /CRUD/Delete/5

            [HttpPost, ActionName("Delete")]
            [ValidateAntiForgeryToken]
            public ActionResult DeleteConfirmed(int id)
            {
                Emp emp = db.Emps.Find(id);
                db.Emps.Remove(emp);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            protected override void Dispose(bool disposing)
            {
                db.Dispose();
                base.Dispose(disposing);
            }
        }
    }

index.cshtml

    @model IEnumerable<MvcApplication2.Emp>

    @{
        ViewBag.Title = "Index";
    }

    <h2>Index</h2>

    <p>
        @Html.ActionLink("Create New", "Create")
    </p>
    <table>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.EmployeeID)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Firstname)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Lastname)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Age)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Project)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Address)
            </th>
            <th></th>
        </tr>

    @foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.EmployeeID)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Firstname)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Lastname)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Age)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Project)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Address)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new {  /*id=item.PrimaryKey */ }) |
                @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
                @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
            </td>
        </tr>
    }

    </table>

Create.cshtml

    @model MvcApplication2.Emp

    @{
        ViewBag.Title = "Create";
    }

    <h2>Create</h2>

    @using (Html.BeginForm()) {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)

        <fieldset>
            <legend>Emp</legend>

            <div class="editor-label">
                @Html.LabelFor(model => model.EmployeeID)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.EmployeeID)
                @Html.ValidationMessageFor(model => model.EmployeeID)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Firstname)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Firstname)
                @Html.ValidationMessageFor(model => model.Firstname)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Lastname)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Lastname)
                @Html.ValidationMessageFor(model => model.Lastname)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Age)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Age)
                @Html.ValidationMessageFor(model => model.Age)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Project)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Project)
                @Html.ValidationMessageFor(model => model.Project)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Address)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Address)
                @Html.ValidationMessageFor(model => model.Address)
            </div>

            <p>
                <input type="submit" value="Create" />
            </p>
        </fieldset>
    }

    <div>
        @Html.ActionLink("Back to List", "Index")
    </div>

    @section Scripts {
        @Scripts.Render("~/bundles/jqueryval")
    }

edit.cshtml

@model MvcApplication2.Emp

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>

@using (Html.BeginForm()) {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Emp</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.EmployeeID)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.EmployeeID)
            @Html.ValidationMessageFor(model => model.EmployeeID)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Firstname)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Firstname)
            @Html.ValidationMessageFor(model => model.Firstname)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Lastname)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Lastname)
            @Html.ValidationMessageFor(model => model.Lastname)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Age)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Age)
            @Html.ValidationMessageFor(model => model.Age)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Project)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Project)
            @Html.ValidationMessageFor(model => model.Project)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Address)
            @Html.ValidationMessageFor(model => model.Address)
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

Image of Solution Explorer: Solution Explorer

I'm successful in creating an application for Tracking Email Reads using ASP.NET by following the below url

http://www.aspnetemail.com/samples/emailtracker/

Everything is working fine but its not working with Gmail. Gmail is appending its own path in src attribute.

![Gmail appended src] : https://i.stack.imgur.com/1NfqL.png

Need your suggestions on further approach to fix this.

I'm developing MVC 2 web application. I'm using FormsAuthentication for sign in users to my application. I want to generate an authentication token after users are successfully login to the application. I have to pass that authentication token to another application. Are there any best ways to accomplish this task using MVC2(.net framework 4.0). Please help me to solve this problem.

First of all thank you guys for your help here.

I need to make a registratin form using BootStrap Form (http://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_form_horizontal_all&stacked=h). MY question is, how to save data in database and perform validation like compare validation for password, required validaton, as we can easily achieve this by server control like textbox, and validation control in asp.net. But I don't have any idea,if we use HTML control and perform same task.

Regards, Ravindra Bisht

I am getting a 404 serving a PDF file

The file exists I can go to IIS , content view, right click, BROWSE and the pdf shows as expected. Other PDFs in this directory are behaving corectly.

Any ideas what could be wrong? The name of the file is this

2016 10 27  WO 43337 Ski Insp.pdf

My doc links have an onClick that shows the doc in a different window. Again, all this works well. Many other documents are working correctly.

Public Function ShowAttachmentJS(Attachmentid As Integer) As String
    Dim a As Attachment = Attachment.AttachmentById(Attachmentid)
    Return "javascript:window.open('" & ShowAttachmentURL(a) & "','','');return false;"
End Function

'//this has to be here cause it needs the page object to resolveurl
Public Function ShowAttachmentURL(a As Attachment) As String

    Dim s As String = String.Format("~/attachments/{0}/{1}", a.FolderFromDocType(), a.FileName)
    Return Me.ResolveUrl(s)

End Function

I developed an e commerce site in asp C# where i need to send an Sms alert on owner's mobile every time some customer places order. Is there any cost free way for handling this? Please provide me complete code for this SMS service (as i am new in C#)

I'm contacting you because I don't know how to send data from a UserControl to another one.

Context:

The first UserControl, UrlControl (uc1) have a TextBox and a LinkButton who allow the user to add a URL to an Event (into my database.)

The other UserControl, TileColorControl (uc2) allow the user to add some colors in his Event. An added color may be attached to all urls or to a specific url. In this controls, there is a DropDownList that contains the different url of the Event.

What I want to is: When I create a new URL by clicking "Add" (in uc1), the DropDownList (in uc2) refresh himself automaticaly with the updated data.

This is what I want to do

Thanks in advance for your help

UrlControl (uc1) code

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FillUrls();
        }
    }
    private void FillUrls()
    {
        RepeaterUrl.DataSource = UrlController.FindByEvent(EventId);
        RepeaterUrl.DataBind();
    }
    protected void LinkButtonSaveNew_Click(object sender, EventArgs e)
    {
        string txtUrl = TextBoxNewUrl.Text;
        if (UrlController.IsValidUrl(txtUrl))
        {
            DMCAccess.Event evt = EventController.FindByUrl(txtUrl);
            if (evt != null)
            {
                btnMsgFailed.Visible = false;lbInfo.Visible = false;
                showMsgAlreadyUsed(evt);
            }
            if (!UrlController.IsAlreadyExist(txtUrl))
            {
                Guid userGuid =                      PersonsController.GetPersonByUserGuid((Guid)Membership.GetUser().ProviderUserKey).Guid;
                Url url = new Url
                {
                    Guid = Guid.NewGuid(),
                    UrlLink = TextBoxNewUrl.Text,
                    IsDeleted = false,
                    EventGuid = EventId,
                    CreationByGuid = userGuid,
                    ModificationByGuid = userGuid,
                    CreationDate = DateTime.Now,
                    ModificationDate = DateTime.Now
                };
                UrlController.Create(url);
                msgSuccess("http://" + url.UrlLink + " was created");
                FillUrls();
            }
        }
        else
        {
            HyperLinkViewEvent.Visible = false;
            msgFailed("Please, enter a valid URL.");
        }
    }

TileColorControl (uc2) code

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FillColors();
            FillUrls();
        }
    }

    protected void RepeaterColor_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            DropDownList ddlUrls = (DropDownList)e.Item.FindControl("ddlUrls");
            ddlUrls.DataSource = urls();
            ddlUrls.DataTextField = "Value";
            ddlUrls.DataValueField = "Key";
            ddlUrls.DataBind();
            ddlUrls.Items.Insert(0, new ListItem("Default", Guid.Empty.ToString()));

            Guid? urlGuid = ((DMCAccess.TileColor)e.Item.DataItem).UrlGuid;
            if (urlGuid.HasValue)
            {
                ddlUrls.SelectedIndex = ddlUrls.Items.IndexOf(ddlUrls.Items.FindByValue(urlGuid.Value.ToString()));
            }
        }
    }

    public void FillUrls()
    {
        DropDownListBoxUrl.DataSource = urls();
        DropDownListBoxUrl.DataTextField = "Value";
        DropDownListBoxUrl.DataValueField = "Key";
        DropDownListBoxUrl.DataBind();
        DropDownListBoxUrl.Items.Insert(0, new ListItem("Default", Guid.Empty.ToString()));
    }

    private Dictionary<Guid, string> urls()
    {
        Dictionary<Guid, string> dUrls = new Dictionary<Guid, string>();
        foreach (Url u in UrlController.FindByEvent(EventId))
        {
            dUrls.Add(u.Guid, u.UrlLink);
        }
        return dUrls;
    }

    private void FillColors()
    {
        TextBoxNewIdColor.Text = TileColorController.MaxColorIdByEvent(EventId).ToString();
        if (UrlController.FindByEvent(EventId).Count < 1)
        {
            upNoWebsite.Visible = true;
            upColor.Visible = false;
        }
        RepeaterColor.DataSource = TileColorController.FindByEvent(EventId);
        RepeaterColor.DataBind();
    }

I'm attempting to do versioning with ASP.NET Web API. I have created a simple controllerselector that derives from DefaultHttpControllerSelector.

public class MyHttpControllerSelector : DefaultHttpControllerSelector
{
    public MyHttpControllerSelector(HttpConfiguration config) : base(config) { }

    public override string GetControllerName(HttpRequestMessage request)
    {
        return "SomeControllerName";
    }
}

In my WebApiConfig.Register:

config.MapHttpAttributeRoutes();

config.Services.Replace(typeof(IHttpControllerSelector), new MyHttpControllerSelector(config));

My problem is GetControllerName is never called. I may be misunderstanding the intent of this function, but I have seen plenty of examples, some right from Microsoft that use this method.

What am I missing?

I am working on a ASP.Net 4.5 Webforms application, but need a functionality similar to a Single-Page-Application (SPA) . I have few controls at the top (textboxes, buttons etc) and want a gridview displayed at the bottom of the page in response to button clicks.

I am aware of AJAX update panel, but am not very much keen on the full-page-cycle it comes with in the back. I need something very simple like a client side javascript code that talks to the server which returns database results back to the browser and then the javascript code constructs a table from the search results. How can this be achieved without implementing frameworks like Knockout, Angular etc just by using plain javascript or with some very lightweight javascript library?

I have a web service accepting data from client applications, but now the owner wants to change the domain of the web service. If i 301 redirect the old domain to the new domain, will the web service still function normally? Im trying to avoid the need to update all the client applications which are numerous.

I think I'm missing an understanding of a development process under Azure AD. I develop a web app, that is authenticated via AD in our corp network, and uses some of our services (like Sharepoint and PowerBI).

It seems like for some of the functionality of Sharepoint, I need administrator consent (In app permissions I had to set Admin: Required). When I try to go to my app (which is located on localhost), it displays this:

this application requires application permissions to another application. 
Consent for application permissions can only be performed by an administrator. 
Sign out and sign in as an administrator or
         contact one of your organization's administrators.

As I understood a Global Administrator need to sign in into an application once, so other users (like me) could log in. But this workflow sounds faulty, I cannot ask our admin to go to my pc and sign in (I have a web app on localhost, so I cannot send him the link). Futhermore, what to do if he is located geographically in another place and just cannot go to my pc? He is also not ready to give me global admin rights just because of this.

This just sounds weird, and I feel like I simply missing something obvious. How do people actually develop such things without asking IT to get to their PCs each time they change something in auth logic?

Can anyone clarify me how can I call the function after update panel refresh. I have read the reference thru this Link, but I dont know what to give in the "call function here" place.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type = "text/javascript">
        var jq5 = $.noConflict(true);
        jq5(document).ready(function () {
            var CheckAll = jq5("#chkAll").click(function () {
                if (this.checked) {
                    jq5('.chk').attr('checked', this.checked);
                }
                else {
                    jq5('.chk').attr('checked', this.checked = false);
                }
            });
            jq5(".chk").click(function () {
                if (jq5(".chk").length == jq5(".chk:checked").length) {
                    jq5("#chkAll").attr("checked", "checked");
                } else {
                    jq5("#chkAll").removeAttr("checked");
                }
            });
        });

    var prm = Sys.WebForms.PageRequestManager.getInstance();
    if (prm != null) {
        prm.add_endRequest(function (sender, e) {
            if (sender._postBackSettings.panelsToUpdate != null) {
                // call function here...
            }
        });
    };
</script>

I have an ASP .NET Core self-hosted project. I am serving up content from a static folder (no problem). It serves up images cross-site without issue (CORS header shows up). However, for some file types, such as JSON, they CORS headers don't show up, and the client site can't see the content. If I rename the file to an unknown type (such as JSONX), it gets served with CORS headers, no problem. How can I get this thing to serve everything with a CORS header?

I have the following CORS policy set up in my Startup.cs:

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddCors(options =>
        {
            options.AddPolicy("CorsPolicy",
                builder => builder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader()
                .AllowCredentials() );
        });

        // Add framework services.
        services.AddMvc();
    }

And the following is my Configure

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        app.UseCors("CorsPolicy");
        loggerFactory.AddConsole(Configuration.GetSection("Logging"));
        loggerFactory.AddDebug();

        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            app.UseBrowserLink();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
        }

        // Static File options, normally would be in-line, but the SFO's file provider is not available at instantiation time
        var sfo = new StaticFileOptions() { ServeUnknownFileTypes = true, DefaultContentType = "application/octet-stream", RequestPath = "/assets"};
        sfo.FileProvider = new PhysicalFileProvider(Program.minervaConfig["ContentPath"]);
        app.UseStaticFiles(sfo);

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });
    }