Subscribe: Web Forms
Added By: Feedage Forager Feedage Grade B rated
Language: English
button  changefreq  messagebox  new  priority  rootnode appendchild  runat server  runat  server  text  textbox  user  xmldoc createelement 
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: Fri, 21 Oct 2016 08:24:52 -0700


Regex Help


I am not overly familiar with regex and have the following scenario to cater for...

I need to identify a text phrase which can have optional break tags around it... so i want to remove instances of-

My line of text.


My line of text.


My line of text.

How do i use regex to identify these variations?

I tried a basic ^My line of text$ regex but this didnt remove the phrase from the paragragh...

any help appreciated

How to get selected value from multiselect dropdownlist


Hi! I want to get value from multiselect dropdownlist and add the selected value to where clause in linq query. How can I do that please.

Here's my dropdownlist: 

<%: Html.DropDownList("structure", (MultiSelectList)ViewBag.structure, new { multiple = "multiple"}) %>  
<%: Html.DropDownList("direction", (MultiSelectList)ViewBag.direction, new { multiple = "multiple"}) %>  

My controller:

var structureQry = db.STRUCTURE_HIER.Select(c => new
Text = c.LIBELLE,
ViewBag.structure = new MultiSelectList(structureQry, "Value", "Text");

var directionQry = db.DIRECTION.Select(c => new
Text = c.DIRECTION1,

I want to do: 

from d from db.AGENT

where d.ID_STRUCTURE == "id_structure_value"

select d

Thank you very much!!!

.net core Authentication with identity doesn't run my action


I am trying to use Cookie authentication in my .net core MVC project. The process is that After Registration I have an entry in the ASPNetUsers table and I have extended this table to include a userType. After the user has logged in I can see that there is a cookie in the cookies collection through the chrome browser. When I try to redirect the user after login it fails. If I adorn the method I'm redirecting with 

 the method gets hit, so I know the redirect is correct.

At the top of my controller I have 

[Authorize(ActiveAuthenticationSchemes = "Cookie")]

When I start the application I register Identity with the following bit of code:

            config => { config.User.RequireUniqueEmail = true;
                config.Cookies.ApplicationCookie.LoginPath = "/Account/Login";
                config.Cookies.ApplicationCookie.Events = new CookieAuthenticationEvents()
                    OnRedirectToLogin = async ctx =>
                        if (ctx.Request.Path.StartsWithSegments("/visualjobs") && ctx.Response.StatusCode == 200)
                            ctx.Response.StatusCode = 401;
                        await Task.Yield();

and in the configuration of start up I have:


        app.UseCookieAuthentication(new CookieAuthenticationOptions()
            AuthenticationScheme = "Cookie",
           // LoginPath = new PathString("/Account/Login/"),
            AutomaticAuthenticate = false

What have I missed?

Error when using a DDL for the of a LIstView control


In a VS2010/ASP.NET4 webpage, I have had a ListView control for editing and adding data.  Inside the , I added a DDL:
DataTextField="Unit" DataValueField="UnitID"
SelectedValue='<%# Bind("UnitID") %>' AutoPostBack="True">

While editing a data record, the DDL did show up for the Unit field.  I changed the Unit and clicked Update button, then an error popped up:
Cannot insert the value NULL into column 'UnitID', table 'Employee'.  

What's wrong? 

Language in browser



I want to implement Localization in my MVC application so I changed in..

1. Web.config -     

2. Home controller index - 

string language = CultureInfo.CurrentCulture.ToString();
CultureInfo culture = null;
                if (language == "en")
                    culture = new CultureInfo(ConfigurationManager.AppSettings["DefaultCulture"]);
                else if (language == "it")
                    culture = new CultureInfo(ConfigurationManager.AppSettings["ItalianCulture"]);
                else if (language == "pl")
                    culture = new CultureInfo(ConfigurationManager.AppSettings["PolishCulture"]);
                else if (language == "sv")
                    culture = new CultureInfo(ConfigurationManager.AppSettings["SwedishCulture"]);
                    culture = new CultureInfo(ConfigurationManager.AppSettings["DefaultCulture"]);
                Thread.CurrentThread.CurrentCulture = culture;
                Thread.CurrentThread.CurrentUICulture = culture;                

3. Added resource file in App_GlobalResources

4. View - 


And changed my google chrome browser's language to Polish. But still not getting the string in Polish.

Please advise where I am going wrong.

How to display information in a label


Hello there,

I'm running a SP using ADO.NET. I'm providing today's date and a value selected from a dropdown to a SP.  If the resulting datatable is not empty, I format the returned date as follows:

if (dtResults.Rows.Count > 0)
   DateTime dtDate = (DateTime)dtResults.Rows[0]["caldate"];
   lblDate.Text = dtDate.ToString("D", CultureInfo.GetCultureInfo("en-US"));

How to display lblDate.Text in my view? I'm new to MVC and I want to display the value of dtDate.ToString("D", CultureInfo.GetCultureInfo("en-US")); in my view. Can someone help me?


XML Nodes development, any short of this method


class Program
        static void Main(string[] args)
            XmlDocument xmlDoc = new XmlDocument();
            XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null);
            XNamespace xmlns = "";
            XElement root = new XElement(xmlns +"urlset");



            XmlNode rootNode = xmlDoc.CreateElement("url");

            XmlNode userNode = xmlDoc.CreateElement("loc");
            userNode.InnerText = "";

            XmlNode changefreq = xmlDoc.CreateElement("changefreq");
            changefreq.InnerText = "yearly";

            XmlNode priority = xmlDoc.CreateElement("priority");
            priority.InnerText = "0.4";

            XmlNode OurpRocesssuserNode = xmlDoc.CreateElement("loc");
            OurpRocesssuserNode.InnerText = "";

            XmlNode OurProcesschangefreq = xmlDoc.CreateElement("changefreq");
            OurProcesschangefreq.InnerText = "yearly1";

            XmlNode OurProcesspriority = xmlDoc.CreateElement("priority");
            OurProcesspriority.InnerText = "0.41";

            XmlNode AboutUsNode = xmlDoc.CreateElement("loc");
            AboutUsNode.InnerText = "";

            XmlNode AboutUschangefreq = xmlDoc.CreateElement("changefreq");
            AboutUschangefreq.InnerText = "monthly";

            XmlNode AboutUspriority = xmlDoc.CreateElement("priority");
            AboutUspriority.InnerText = "0.2";

            XmlNode CareersNode = xmlDoc.CreateElement("loc");
            CareersNode.InnerText = "";

            XmlNode Careerschangefreq = xmlDoc.CreateElement("changefreq");
            Careerschangefreq.InnerText = "daily";

            XmlNode CAreerspriority = xmlDoc.CreateElement("priority");
            CAreerspriority.InnerText = "0.3";




I want to make the code to short as much . a parameter or parameters will be passed & they generate XML like the above XML.?

how to make this XML




How to make this XML?

Bootstrap scrollspy is Jumping second to last option


Hi All, I used Bootstrap scrollspy in my page.  When I am scrolling the page it is jumping from second option to last. Click on each option is not also going to specific section.

About Birth Defects

Birth defects (also called congenital malformations) are conditions that happen when a baby does not develop normally during pregnancy. Structural defects may include missing limbs, malformed hearts, spina bifida and genetic conditions like Down syndrome. Most birth defects happen during the first three mo[...]

binding to checkboxes or listboxes issues


I need to create checkboxes dynamically based on the result set from a table.... then I need to have those checkboxes be check if the main record has those items... for example I have a reference table for environments that have up to 4 records indicating 4 different environments to run.   The service record driving this may be run in maybe 3 of the 4 environments.   I need to display the 4 environments as checkboxes and have 3 of the checkboxes "checked" for that particular service record.  My question is how?  I can get the checkboxes created dynamically but how do I check them in relation to the main record I am displaying?   feel a little like Im chasing my tail here... any help would be appreciated.

I tried to find examples of this but it seems that MVC tutorials only believe UIs use labels and textboxes... nothing really meaty... although I hope to be proved wrong.  A good tutorial or example would really help.


Prevent PostBack on a LinkButton stop the (first) next UpdatePanel postback Trigger?


Hi all!

I've two LinkButton: one to check the validators (and must prevent postback), once do somethings for an UpdatePanel:

Add Prosegui

This is the JavaScript function I manually use for validation:

function Prosegui() {
if (Page_ClientValidate("richiestaIscrizione")) {

function SwitchToRiepilogo() {

The problem is that, once I validate, the next "click" on cmdAggingiPartecipante do nothing (i.e. no asynch postback start). I need to click on it again to trigger the UpdatePanel's postback.

Instead, if I remove OnClientClick="Prosegui(); return false;" from cmdProsegui, .NET automatically check the validators, and the next click on cmdAggingiPartecipante works perfect, as aspected!

The problem is that if Validation success, it does postback (which is what I want to avoid).

Why this? What does LinkButton internal validation do that my JavaScript function miss?

The problem seems to be in WebForm_DoPostBackWithOptions with clientSubmit enabled:

function WebForm_DoPostBackWithOptions(options) {
var validationResult = true;
if (options.validation) {
	if (typeof(Page_ClientValidate) == 'function') {
		validationResult = Page_ClientValidate(options.validationGroup);
if (validationResult) {
	if ((typeof(options.actionUrl) != "undefined") && (options.actionUrl != null) && (options.actionUrl.length > 0)) {
		theForm.action = options.actionUrl;
	if (options.trackFocus) {
		var lastFocus = theForm.elements["__LASTFOCUS"];
			if ((typeof(lastFocus) != "undefined") && (lastFocus != null)) {
				if (typeof(document.activeElement) == "undefined") {
					lastFocus.value = options.eventTarget;
				else {
					var active = document.activeElement;
					if ((typeof(active) != "undefined") && (active != null)) {
						if ((typeof( != "undefined") && ( != null) && ( > 0)) {
							lastFocus.value =;
						else if (typeof( != "undefined") {
							lastFocus.value =;
	if (options.clientSubmit) {
		__doPostBack(options.eventTarget, options.eventArgument);

If I set it to true, the validation + triggers works (but it does postback). If I set it to false, validation works, postback is prevented, but next triggers doesn't works.

I'm going crazy with this trouble... any helps?

How to redirect user to a page when unauthorize error occur


when user not login and if he try to access protected page then login form comes but when user logged in but try to access a page for which he has not a specific roles then what will happen ? again login form will comes.

in this kind of situation i want to redirect user to a specific page where i will show him a friendly message like "You do not have HR role so can not access this page"

please guide me how could i do it. thanks

Logged out of ASP NET Core site on IIS after 5 minutes of inactivity



When running my ASP NET CORE MVC site on IIS I notice that after 5 minutes of no requests, I get logged out of the site (I'm using Identity with cookies authentication).

I suspected this being caused because of the app pool shutting down of inactivity, thus losing any session memory related to the user.

So when in Staging/Production environment, I replaced the InMemoryDatabase for a SqlServer. But I am still having this problem, and I see some weird exceptions of a key not being found in a key ring. I just want the cookies or whatever is needed to persist (either in the sql server or the drive).

These are the important files in the project.



Log file when logged out


Login portion of the code

I apologize if I'm missing important details, let me know if I do. Thanks for reading. 

issue with custom message box



I have to implement a custom message box in ASP.NET. I have added code from the following web link:

After this, I added a test.aspx page in the solution explorer of Visual Studio 2010. In test.aspx, I added three text boxes and 1 button. The code in the source window is as follows:


The code for Button1_Click is as follows:

        protected void Button1_Click(object sender, EventArgs e)
            if (TextBox1.Text == string.Empty)
                MessageBox messageBox = new MessageBox();
                messageBox.MessageTitle = "Test";
                messageBox.MessageIcons = MessageBox.MessageBoxIcons.Error;
                messageBox.MessageText = "Fill Text Box1";
                Literal1.Text = messageBox.Show(this);
            if (TextBox2.Text == string.Empty)
                MessageBox messageBox = new MessageBox();
                messageBox.MessageTitle = "Test";
                messageBox.MessageIcons = MessageBox.MessageBoxIcons.Error;
                messageBox.MessageText = "Fill Text Box2";
                Literal1.Text = messageBox.Show(this);
            if (TextBox3.Text == string.Empty)
                MessageBox messageBox = new MessageBox();
                messageBox.MessageTitle = "Test";
                messageBox.MessageIcons = MessageBox.MessageBoxIcons.Error;
                messageBox.MessageText = "Fill Text Box3";
                Literal1.Text = messageBox.Show(this);

When I view test.aspx in Browser, the message box appears even when all text boxes are filled. It should not be the case, the program should exit gracefully when all text boxes are filled. My steps are as follows and the issue/problem faced is mentioned in the last:

1. Clicked Button1. Message: Fill Text Box1

2. Filled TextBox1 and clicked Button1. Message: Fill Text Box2

3. Filled TextBox2 and clicked Button1. Message: Fill Text Box3

4. Filled TextBox3 and clicked Button1. 

Now clicking Button1 should end the function Button1_Click because all Text Boxes are filled. However clicking Button1 at this stage again shows the message Fill Text Box3. At this moment, clicking OK does not remove the message box too.

How could i protect aspx page role wise ?


i read few article on the role and authorization. i saw when user login they fetch the role based on user id and store those roles in auth cookie and from Application_AuthenticateRequest event then fetch the role from auth cookie and assign those roles to GenericPrincipal . one thing is not clear how user will be deny to access a pages even after being authenticated if user has no roles called HR.

suppose i have a 3 type of roles called user, HR, Admin. when a user login with HR role and if he try to access admin page then he should not allow to access that page rather he should be redirected to unauthorized page where we will show friendly message that you do not have access. how could i protect page role wise.

one link which i read

just tell me can we protect pages with location tag in web.config where i will specify role name. see my below script













please guide me. thanks

form inline horizontal to verical


Hi folks,

Here is my sample code.
I do not want like this:


Any Idea?
I am waiting for your response
Thanks in Advance

Dynamic Bootstrap Accordion Show/Collapse using jquery


Hello Everyone,

I am new to Bootstrap Accordion. 

I have a dynamic Bootstrap Accordion panel. I want to dynamically show/collapse the panels using jquery and 

glyphicon glyphicon-plus
glyphicon glyphicon-minus

@foreach (var groupedItem in @Model.ActionDetail) { if (phaseId != groupedItem.PhaseId.ToString()) //Phase { phaseId = groupedItem.PhaseId.ToString(); //Set the PhaseId to skip render its actions } else //Action {
@foreach (var item in @Model.ActionDetail.Where(p => p.PhaseId == groupedItem.PhaseId)) {
@Html.ActionLink(item.Action, "ShowActionComponents", new { controller = "ActionComponents", ProjectId = item.ProjectId, ActionId = item.ActionId, Action = item.Action })
@{ if (item.ToolTip != null && item.ToolTip != "") { } }
} }

$(document).ready(function () {

$('#accordion .panel-heading').find('a').prepend('');




Delete column from excel worksheet using EPPLUS in c#


I want role based column to be shown in download excel.if user is Admin he can see all fields in excel, if he is normal user he only see selected fields .So for normal user i have list of column names that will be Deleted(or hide or Disabled) .

i made template excel With all fields-Names and sequentially adding data from datatable' 2nd row so I have customized column name without Database colume name to be shown.

here is my approach 

using (ExcelPackage xlpackageInsertEmployee = new ExcelPackage(workBookInsertEmployeedetails))
                if (dtEmployeeDetails != null && dtEmployeeDetails.Rows.Count > 0)
                    ExcelWorksheet worksheetInsertEmployees = xlpackageInsertEmployee.Workbook.Worksheets["EmployeeDetails"];
                    worksheetInsertEmployees.Cells[2, 1, dtEmployeeDetails.Rows.Count + 1, dtEmployeeDetails.Columns.Count + 1].LoadFromDataTable(dtEmployeeDetails, false);
                //here i want to delete or disable or hide column based on column name that i want to Hide
xlpackageInsertEmployee.Save(); } } Response.ContentType = "application/"; string fileName = Server.MapPath("~/EmployeeData.xlsx"); Response.AppendHeader("Content-Disposition", "attachment; filename=EmployeeData.xlsx"); Response.TransmitFile(fileName); Response.End();

Now i Want to hide Emp Mobile Number and Email how to do so . 

Note- I will Upload same on server 

SSRS 2008 How to rollup values using a group and recursive parent



Im having an issue where I can't get my row values to total upwards when using a tablix and the 'recursive parent' option.  The following should help explain what im trying to achieve:

My Dataset:

;with cols as
 SELECT 1 colID, 'C1' col
, rows as
 SELECT 1 RowID, 'R1' row, null ParentID
 UNION SELECT 2, 'R2', 1
 UNION SELECT 3, 'R3', 2 
 UNION SELECT 4, 'R4', 2 
 UNION SELECT 5, 'R5', 1 
 UNION SELECT 6, 'R6', 1 
 SELECT 3 RowID, 1 as Amount
 UNION SELECT 4 RowID, 2 as Amount
SELECT r.RowID, r.row, c.colID, c.col, d.Amount, r.ParentID
FROM rows r 
LEFT JOIN data d on d.RowID = r.RowID

In my 'RowGroup' properties I go to 'advanced' and then set 'Recursive parent' to be 'ParentID'  and I've also set the padding left to be '=level()*20 & "pt"' to show the indent of the parent - child relationship

My matrix configuration and output looks like the following.  Notice how R1 and R2 have no values.  I want them to show '3' as this is the rolled up total of the children rows.


Thanks for all your help

TextBox is Empty onRoweditting event of gridview in c# ?


My edit template textboxes are empty when i click to edit button . Here is RowEditingEvent  protected void grdLocation_RowEditing(object sender, GridViewEditEventArgs e) { DataTable dt = ViewState["dtgetPackages"] as DataTable; grdLocation.DataSource = dt; grdLocation.EditIndex = e.NewEditIndex; grdLocation.DataBind(); //Bindgrid(); i used this method directly but same result as above this function is working fine } if i remove Bindgrid(); function I need double click to edit button to go into edit mode .. in that case my text boxes are filled with right values and working fine . only problem is double click requires on edit button here is Gridview Edit [...]