I have an EPIServer related question.

I use @Html.PropertyFor() to render an XHTML string. The rendered html is then used in an email that I send to my customers.

The issue is that I have an link in my email, which links to a a subpage on my page. (e.g. if my EPIServer is running at /localhost/, then I might link to /localhost/my_subpage/ in the email that I send out).

The problem is that @Html.Propertyfor() renders all links as friendly URLs, which means that the URL in my email then becomes /my_subpage/ instead of /localhost/my_subpage/. Not that surprisingly, the friendly internal link does not work in an email.

I am new to EPIServer (which this question might reveal), but I really believe, I have looked deeply into this, without finding any way to have it render absolute URLs. Does anyone know, if this is possible with EPIServers HTML helper?

I'm implementing a website using asp.net MVC. I'm trying assign role to user by clicking into the role. I've tried several ways, unfortunately, I failed.

Controller method

[HttpPost,ActionName("AssignUserToRole")]
[ValidateAntiForgeryToken]
[CustomAuthorize(Roles ="SudoAdmin")]
public ActionResult AssignUserToRole(long userId, long roleId)
{
    new BusinessUser().AddRoleToUser(userId, roleId);

      return RedirectToAction("Index");
}

view

 @Html.ActionLink(@r.RoleName, "AssignUserToRole", "Users", new { userId = Model.UserId, roleId = r.RoleId })

first I tried Jquery Ajax, but it failed, even though I think it was not a very great idea. However, I still would like to do it with "Ajax"I mean without refreshing the page.

I hope my question is good enough thanks for all of you

I'm developing an ASP.NET application that's required to stream on-demand videos from server to client. Now I consider using DirectShow to do some kind of processing works before the video is transmitted over Internet. Following this article, I know I can transfer video stream over network through WMAsfWriter after it's processed by DirectShow and the output is a URL that the client can get access to through Windows Media player. But in my ASP.NET application, I want the video stream played on the web page of the client browser such as Chrome. I'm not sure if the output URL can be parsed by client browser and the video stream can be played there directly, so I want to ask that is it possible? If not, what extra steps do I need to take to achieve my goal?

I am trying to plot a mutibar column chart with legend. This is my code. The code is seems to be working but its not adding legend in an appropriate format. I'm adding screenshots of my data table and the output coming from my code. The legend should be showing Different types of priorities but its showing "Legend Text" everywhere.

Output

Datatable

//Plotting Matrix Chart
        chartMatrix.Visible = true;
        LoadChartData(dtHourvsPriorityMatrix);
        chartMatrix.Series["Priority"].ChartType = SeriesChartType.Column;
        chartMatrix.Series["Priority"]["DrawingStyle"] = "Emboss";
        //chartMatrix.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
        chartMatrix.Series["Priority"].IsValueShownAsLabel = true;

        // Create a new legend called "Legend".
        chartMatrix.Legends.Add(new Legend("Legend"));

        // Set Docking of the Legend chart to the Default Chart Area.
        chartMatrix.Legends["Legend"].DockedToChartArea = "ChartAreaF";

        // Assign the legend to Series=Priority.
        chartMatrix.Series["Priority"].Legend = "Legend";
        chartMatrix.Series["Priority"].IsVisibleInLegend = true;

        LegendCellColumn lcc = new LegendCellColumn("Priority", LegendCellColumnType.Text, "LEGENDTEXT");
        lcc.HeaderFont = new System.Drawing.Font("Trebuchet MS", 12F, System.Drawing.FontStyle.Bold);
        chartMatrix.Legends["Legend"].CellColumns.Add(lcc);


private void LoadChartData(DataTable initialDataSource)
    {
        for (int i = 1; i < initialDataSource.Columns.Count; i++)
        {
            Series series = new Series();
            foreach (DataRow dr in initialDataSource.Rows)
            {
                int y = (int)dr[i];
                series.Points.AddXY(dr["Hour"].ToString(), y);
            }
            chartMatrix.Series.Add(series);
        }
    }   

Good Day! Can anyone help me on how to use Stored procedure with parameters in Crystal Reports using VS 2013 asp.net MVC razor?

This is my code:

 public ActionResult AllCustomerReports()
    {
        ReportDocument rd = new ReportDocument();
        rd.Load(Server.MapPath("\\Reports\\rpt_AllCustomers.rpt"));
                    rd.SetDataSource(db.CUSTOMERs.Select(p => new
        {
            Id = p.Id,
            CUSTOMER_CODE = p.CUSTOMER_CODE,
            CUSTOMER_NAME = p.CUSTOMER_NAME,
            CUSTOMER_EMAIL_ADDRESS = p.CUSTOMER_EMAIL_ADDRESS,
            CUSTOMER_LANDLINE = p.CUSTOMER_LANDLINE,
            CUSTOMER_TYPE_ID = p.CUSTOMER_TYPE.Id,
            CUSTOMER_TYPE_NAME = p.CUSTOMER_TYPE.CUSTOMER_TYPE_NAME,
            LOCATION_TYPE_ID = p.LOCATION_TYPE.Id,
            LOCATION_TYPE_NAME = p.LOCATION_TYPE.LOCATION_TYPE_NAME,
            INDUSTRY_TYPE_ID = p.INDUSTRY_TYPE.Id,
            INDUSTRY_TYPE_NAME = p.INDUSTRY_TYPE.INDUSTRY_TYPE_NAME
        }).ToList());

        Response.Buffer = false;
        Response.ClearContent();
        Response.ClearHeaders();
        Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
        stream.Seek(0, SeekOrigin.Begin);
        return File(stream, "application/pdf", "ListofAllCustomers.pdf");
    }

I need to create a report where I can pass parameter to my SP. How will I do that? Thanks.

I want to validate that all properties in model object used in *.cshtml template. For example if I have 3 properties in model and only one of them used in template I want receive validation error or some notification. Can such validation/notification be done with RazorEngine:

UserModel model = new UserModel() { Name = "Sarah", Email = "sarah@mail.com", IsPremiumUser = false };
string result = Engine.Razor.RunCompile(File.ReadAllText("C:\\testTemplateEmpty.cshtml"), "key", typeof(UserModel), model);

Template:

@model Algomizer.Common.MailManager.MailModels.UserModel
<body>
    <p>
        Hi @Model.Name,
    </p>
</body>

I am accessing the Access%20Requests/pendingreq.aspx list of a Sharepoint site in C#.

When trying to access what in the pendingreq.aspx page is written in the Permission column, I only get numbers like "0" (for a request trying to get Read permissions) or any other numerical code. I could not find a reference for these permission codes.

Is there a way to look up those codes in order to find a written description of the requested permission or do I have to discover and map these codes myself?

I have a gridview in which there are 2 columns such as Status and View

and below is my js code:-

function UltraWebGrid1_Select(sender, records) {
        for (var i = 0; i < records.length; i++) {
            var record = records[i];
            if (record.Status == "Status") {
                window.open('FrmInwardNextAction.aspx?Inward_Mkey=' + record.mkey + "&View=N&Status=" + record.Status + "&IWNO=" + record.Doc_No, '_blank', 'height=670,width=1000,resizable=yes,top=0,left=0,scrollbars=yes');
            }
            if (record.View == "View") {
                window.open('InwardDocDetails.aspx?Key=' + record.mkey + "&View=Y&Status=" + record.Status + "&IWNO=" + record.Doc_No, '_blank', 'height=700,width=1020,resizable=yes,top=0,left=0,scrollbars=yes'); //obout grid
            } 
        }
    }

Currently, If I click on Status my both links of Status as well as View page is opening at the same time.

Here is the fiddle for more details.

UPDATE

Source code HTML of the gridview in the Fiddle

I've got an API application that uses multiple database shards, with StructureMap for dependency injection. One of the required headers in each API call is a ShardKey, which tells me which database this call is addressing. To effect this, I have an OwinMiddleware class called ShardingMiddleware, which contains the following code (snipped for clarity):

var nestedContainer = container.GetNestedContainer();
using (var db = MyDbContext.ForShard(shardKey)) // creates a new MyDbContext with connection string appropriate to shardKey
{
    nestedContainer.Configure(cfg => cfg.For<MyDbContext>().Use(db));
    await Next.Invoke(context);
}

This works beautifully in my test environment and passes a battery of integration tests.

But the integration tests are effectively single-threaded. When I deployed this into a QA environment, where a real app is hitting away at my API with multiple simultaneous calls, things start to go pear-shaped. Ferinstance:

System.ObjectDisposedException: Cannot access a disposed object. A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur is you are calling Dispose() on the context, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.

Or other exceptions indicating that StructureMap does not have a valid instance of MyDbContext available.

To me it seems that the multiple threads are somehow messing up each other's configuration, but for the life of me I can't understand how, seeing as I'm using a nested container to store the database context for each API call.

Any ideas what might be going wrong here?

Update: I also tried abstracting my Db context into an interface. Made no real difference; I'm still getting the error

System.InvalidOperationException: An error occurred when trying to create a controller of type 'SomeController'. Make sure that the controller has a parameterless public constructor. ---> StructureMap.StructureMapConfigurationException: No default Instance is registered and cannot be automatically determined for type 'MyNamespace.IMyDbContext'

Update 2: I solved the problem, but the bounty is still open. Please see my answer below.

i use asp.net mvc and c# i have data table that have many column,one column has 'time' and sotred data like this format

14
16:30
17:05
...

in view i have filter for time and user can select multiple time from check box, my filter check box is

4 - 8
8 - 11
11 - 14
14 - 17
17 - 21
21 - 24

now i want filter from datatable

var result = from r in myDataTable.AsEnumerable()  
            where r.Field<string>("time")  // between any passed time,like between 4-8 and 11-14 and 21-24
                 select r;  
DataTable dtResult = result.CopyToDataTable(); 

my problem is,i dont know user how many pass time , if just passed one time it's easy but i dont know how many time passed

how i can edit code for accept any time and any count of time?

thank you for your help

I have web page that takes some time to load. I have tried to measure and print the page load time in browser console using following javascript code.

     <script type="text/javascript">
     $(document).ready(function () {
         console.log("Time until DOMready: ", Date.now() - timerStart), "ms";
     });
     $(window).load(function () {
         console.log("Time until everything loaded: ", Date.now() - timerStart, "ms");
     });

    </script>

Now i want to store these time in a text file (log file) in the server. Is there a way? Thank you!

0 Points

1 Post Drop Down List Problem

2 minutes ago|LINK

I have a fairly simple question.

I have a drop down list that is populated by a table in my sql database. Now i am retrieve values into drop down list but this values goes to lat row in drop down list (value is machine1) now i want to get value in top by user select Employee name. Image Sample please click

CODES HERE

======================

       string select = "select * from dally_report where Emp_name='" + txt_search.SelectedItem.ToString()+ "'";
        MySqlCommand cmd1 = new MySqlCommand(select, DBConnection.connection());
        MySqlDataAdapter sp = new MySqlDataAdapter();
        MySqlDataReader dr = cmd1.ExecuteReader();

        if (dr.Read())


        {

            txt_date.Text = dr[2].ToString();
            txt_empname.Text = dr[1].ToString();
            txt_jobno.Text = dr[3].ToString();
            txt_machine1.Items.Add (dr[4].ToString()); // This is drop down list


             }

BootStrap Side Navigation Bar

I am working on a Web Application(asp.net) and I don't have much Idea About Bootstrap Side Navigation Bar My superior Love This Design(Design of image) can Anybody help me out on this about how to create a side navigation bar with two value on side by side for e.g in this image(Send sms and campaigns are side by side)

Apparently, when a .NET assembly is created the location of the corresponding .PDF file path is included inside. Link for reference: https://msdn.microsoft.com/en-us/library/ms241613.aspx

How do I access this? I have tried using ILSpy to look inside my assembly but could not find.

I have setup the view MyView.chstml with two submit action. but give me "A circular reference was detected while serializing an object of type 'System.Reflection.RuntimeModule'. How to troubleshoot easily ?

 @using (Html.BeginForm("MyView", "Worker", FormMethod.Post, new { enctype = "multipart/form-data", @name = "formWorker" }))
{
    @Html.AntiForgeryToken()
    <div class="form-horizontal" id="divWork"> ....
        <div class="form-group">
             <button id="btnSubmit" class="btn btn-success" type="submit" value="Work1">Work1</button>
        </div>   
        <div id="Dynamictable" class="table-responsive hidden" name="dtable">
                <table class="table table-bordered" id="dctable" name="dctable"></table>
        </div>

       <div id="dialogsubmit" title="second submit">
                <div id="dialog-content" name="dialog-content" class="form-control hidden">    &nbsp;</div>
            </div>  
   </div>

then in script

    (function () {
    //strangely the below ajax is never called
     $('#formWorker').submit(function () {
        debugger;
        $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize(),
                success: function (result) {
                    debugger;
                    bootbox.alert(result);
                }
            });
            // it is important to return false in order to
            // cancel the default submission of the form
            // and perform the AJAX call
            return false;
     });
    }
      $("#btnSubmit").click(function () {

        if(document.getElementById('dctable').getElementsByTagName("tr").length < 1)
        {
            aRow = document.all("dctable").insertRow();
            var oCell = aRow.insertCell();
            oCell = newRow.insertCell(); 
            oCell.innerHTML = '<input type="submit" name="submit2" value="submit2" />';
            **//strangely if i replace the above RHS with below, it act as submit halft submit form (half becuase the FormCollection object in HttpPost method of controller lacks key submit2 and also HttpPostedFileBase object came as null in controller method ,**  
            *//'<button id="submit2" name="submit2" class="btn submit2" value="submit2" ><i class="fa fa-search"></i> submit2</button>'*
            return false;
        }

      });



   </script>

in controller

       [HttpGet]
        public ActionResult Worker()
        {
            return View();
        }

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Worker(HttpPostedFileBase file, FormCollection form)
        {
          string value = form["submit2"];  //half submit form  as it is null in additon to file is null. if i use commented RHS , all good here, but no option in view to process the output in same view.
          IEnumerable<object> data = Enumerable.Empty<object>();
          if (value != null) // key doesn't exist
          {
            //process here and and return json to shown result on same page using popup/alert.
            return this.Json(
                new 
                {
                    Result = data.ToList()
                }, JsonRequestBehavior.AllowGet
            );
           }
           return PartialView("anoterhView", data.ToList());
        }

I créate an dll and it internal use an com object when the dll method is invoked a thread is created with setapartmentstate sta.

The problem are the cookies in webbrowser it is shared.

So if user enter and start a session And after user 2 enter. user 1 and 2 shared the same session my option is created a console application and invoked it with processstartinfo for created a new process and prevent share cookies

But it have other implications how return result to the correct process in the web server or have use database for save temporarily the result,

So some know if is possible create an thread like do ProcessStartInfo?

Some idea or suggestion?

I cannot get access to The helper @Styles nor @Scripts. I have added <add namespace="System.Web.Optimization" /> as proposed HERE and HERE. I use to have this problem, but i solved it by adding @using System.Web.Optimisation

Here are my configs (the relevant part):

 <system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
  <namespaces>
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Optimisation" />
    <add namespace="System.Web.Routing" />
    <add namespace="CariSSC" />
  </namespaces>
</pages>

I read a couple of blogs online and they all point to the same solution. Any clues on how to fix this?

I have a Kendo Grid in ASP.Net Razor. For the columns that are not hidden on the initial display, the HtmlAttributes "works"; that is, the values are shown as formatted numerical values, aligned to the right.

However, if a another column, otherwise formatted in exactly the same way, is hidden on the initial display, and then added to the grid by the User (by using the column header column picker) - the formatting is not fully utilized; I am seeing the values in the column aligned to the left.

Here's two column from the grid I'm having the problem with.

How can I get the HTML formatting to always apply, regardless of initial visibility?

 columns.Bound(c => c.EarnedCost)
                .HtmlAttributes(new { style = "text-align: right;" }).Format("{0:N2}")
                .ClientFooterTemplate("#=kendo.toString(sum, 'N2')#")
                .FooterHtmlAttributes(new { style = "text-align: right;" });
            columns.Bound(c => c.PayHours).Hidden(true)
                .HtmlAttributes(new { style = "text-align: right;" }).Format("{0:N2}")
                .ClientFooterTemplate("#=kendo.toString(sum, 'N2')#")
                .FooterHtmlAttributes(new { style = "text-align: right;" });

I want to show a modal on another modal while its still visible. I am unable to understand what should I do. I tried z-index but its not working for me. Any kind of guidance is much appreciated.

When I am adding a line "" in my code inoreder to use update panel then on applicatin below error showing -

Failed to map the path '/aspnet_client/system_web/4_5_19/WebForms.js'.

[InvalidOperationException: Failed to map the path '/aspnet_client/system_web/4_5_19/WebForms.js'.] System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath, Boolean permitNull) +9800860 System.Web.Hosting.HostingEnvironment.MapPathInternal(VirtualPath virtualPath) +43 System.Web.Hosting.HostingEnvironment.MapPath(VirtualPath virtualPath) +56 System.Web.VirtualPath.MapPath() +9 System.Web.Handlers.AssemblyResourceLoader.GetDiskResourcePath(String resourceName) +51 System.Web.Handlers.AssemblyResourceLoader.GetWebResourceUrl(Type type, String resourceName, Boolean htmlEncoded, IScriptManager scriptManager, Boolean enableCdn) +418 System.Web.UI.ClientScriptManager.GetWebResourceUrl(Page owner, Type type, String resourceName, Boolean htmlEncoded, IScriptManager scriptManager, Boolean enableCdn) +99 System.Web.UI.ClientScriptManager.RenderWebFormsScript(HtmlTextWriter writer) +118 System.Web.UI.Page.BeginFormRender(HtmlTextWriter writer, String formUniqueID) +943 System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +55 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32 System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +53 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100 System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +128 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +13 System.Web.UI.Control.Render(HtmlTextWriter writer) +12 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +128 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +13 System.Web.UI.Page.Render(HtmlTextWriter writer) +29 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1386

Hi I'm trying to capture two dates selected by the user in a C# Calendar Control and I want the date range to be displayed in a label. I have worked out on the following code but it generates a Minus value ; not the actual date range.

>         DateTime from = CalFrom.SelectedDate;
>         DateTime to = CalTo.SelectedDate;
>         double days = (CalTo.SelectedDate - CalFrom.SelectedDate).TotalDays;
>         TimeSpan t = to - from;
>         double noOfDays = t.TotalDays;
>         TimeSpan ts = to - from;
>         double differnceindays = ts.TotalDays;
>         lblNoofDays.Text = differnceindays.ToString();