Subscribe: Custom Server Controls
http://forums.asp.net/rss.aspx?ForumID=19
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
add  controlparameter controlid  event  htmlattributes new  model model  model  new  odr tostring  odr  public  string  text  tostring 
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: Custom Server Controls

All Forums



All Forums



Last Build Date: Mon, 27 Feb 2017 06:45:26 -0800

 



Question about saving a solution as a template

2017-02-24T19:04:26.42-08:00

Hi

I have build a CMS, off which I plan to run many websites, I have a build the front end website and I want to copy that and use it for all the websites but have different views.

I understand I can save the solution as a template and use that, but the CMS is still evolving and changes often, so my problem is keeping all the other stuff except the views upto date, both files in the folders and with the uploading

Any suggestions and information would be appriciated.




Auto Append text from multi dropdownlist to Textbox

2017-02-26T14:49:55.84-08:00

I one have problem. I one form for user input address.

and my view is

 
@Html.LabelFor(model => model.address, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.EditorFor(model => model.address, new { htmlAttributes = new { @class = "form-control input-sm" } }) @Html.ValidationMessageFor(model => model.address, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.city, "id_city", htmlAttributes: new { @class = "control-label col-md-2" })
@Html.DropDownList("id_city", null, string.Empty, htmlAttributes: new { @class = "form-control input-sm" }) @Html.ValidationMessageFor(model => model.id_city, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.district, "id_district", htmlAttributes: new { @class = "control-label col-md-2" })

and user can it put address in textbox address, and user can chose city,  district, this auto append.

example :

address : 11240 larva street, Ohio , district1 ...




Is there a way for an asp.dropdownlist to use return true; in the javascript function to call the c# codebehind?

2017-02-27T14:21:20.13-08:00

With a textbox and button, using the "return true;" in the function calls the c# codebehind.  For some reason, it isn't working for a dropdownlist. Am I doing something wrong, or do I have to do a __doPostBack(...);

The javascript function gets called, but it behaves as if I have return false.




Where is Visual Studio 2015 local help for System.Web.MVC?

2017-02-27T14:35:49.64-08:00

I installed everything remotely relevant to C#/ASP.Net development in my local help content. However, when I edit CSHTML files, put cursor on Label in @Html.Label and press F1 the help topic that comes up is an online content. When I open it in the browser it becomes clear this help topic is under System.Web.Mvc.Html >LabelExtensions Class > LabelExtensions Methods

When I look at Contents tab in local help under .NET Framework 4.6 and 4.5\.NET Framework Class Library()\System.Web Namespaces() System.Web.MVC doesn't exist there. What I have is System.Web.ModelBinding and the one below is System.Web.Profile Namespace

Can anyone explain this? Can Visual Studio 2015 local help for MVC be downloaded locally at all?




how to get datatable textbox value data in server side

2017-02-27T14:03:51.27-08:00

hello,

i have a jquery datatable in json client side. it make a textbox  for search and data to show in table.i want to get a textbox value and pass it into a procedure in server side.

how can i do this in server side .

plz help me out

thanks for the help




Date Should be Like This DD-MMM-YYYY

2017-02-27T11:36:40.027-08:00

Hello

In my result set its looking like this

2016-10-28 00:00:00.000

But i want like this Format

28-Oct-2016




Regex for not allowing an email ending in: @my.mydomain.com

2017-02-27T13:25:29.9-08:00

What is a regex that I can add to my website where I will NOT allow the email ending in "@my.mydomain.com"

Thanks.




when parent node is checked all child node checkboxes should be checked too

2017-02-27T13:32:17.873-08:00

I have got a treeview derived from the database...

here I want that when a checkbox beside parent node is checked..all the child nodes for that parent node have to be selected(checked)


    
    
    
    
           




J Query Event Calendar in Asp.net - database write error

2017-02-27T11:14:11.857-08:00

I am making a j query event calendar in asp.net using c#. The calendar runs fine but won't write any data to the database(no errors or exceptions are thrown,on refresh it is just gone). I manually entered some dummy data in the database and this does load properly on page start up. All of the database interaction is handled in my EventDAO.cs page and called in the aspx page. Here is my code: EventDAO.cs public class EventDAO { //connection string. private static string connectionString = ConfigurationManager.ConnectionStrings["MainFYPConnectionString"].ConnectionString; //this method retrieves all events within range start-end public static List getEvents(DateTime start, DateTime end) { List events = new List(); SqlConnection con = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand("SELECT event_id, description, title, event_start, event_end, all_day FROM Event where event_start>=@start AND event_end<=@end", con); cmd.Parameters.Add("@start", SqlDbType.DateTime).Value = start; cmd.Parameters.Add("@end", SqlDbType.DateTime).Value = end; using (con) { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { events.Add(new CalendarEvent() { id = Convert.ToInt32(reader["event_id"]), title = Convert.ToString(reader["title"]), description = Convert.ToString(reader["description"]), start = Convert.ToDateTime(reader["event_start"]), end = Convert.ToDateTime(reader["event_end"]), allDay = Convert.ToBoolean(reader["all_day"]) }); } } return events; } //this method updates the event title and description public static void updateEvent(int id, String title, String description) { SqlConnection con = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand("UPDATE Event SET title=@title, description=@description WHERE event_id=@event_id", con); cmd.Parameters.Add("@title", SqlDbType.VarChar).Value = title; cmd.Parameters.Add("@description", SqlDbType.VarChar).Value= description; cmd.Parameters.Add("@event_id", SqlDbType.Int).Value = id; using (con) { con.Open(); cmd.ExecuteNonQuery(); } } //this method updates the event start and end time ... allDay parameter added for FullCalendar 2.x public static void updateEventTime(int id, DateTime start, DateTime end, bool allDay) { SqlConnection con = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand("UPDATE Event SET event_start=@event_start, event_end=@event_end, all_day=@all_day WHERE event_id=@event_id", con); cmd.Parameters.Add("@event_start", SqlDbType.DateTime).Value = start; cmd.Parameters.Add("@event_end", SqlDbType.DateTime).Value = end; cmd.Parameters.Add("@event_id", SqlDbType.Int).Value = id; cmd.Parameters.Add("@all_day", SqlDbType.Bit).Value = allDay; using (con) { con.Open(); cmd.ExecuteNonQuery(); } } //this mehtod deletes event with the id passed in. public static void deleteEvent(int id) { SqlConnection con = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand("DELETE FROM Event WHERE (event_id = @event_id)", con); cmd.Parameters.Add("@event_i[...]



Display a startup webform in the centre of the screen with the windows desktop screen visible in the background

2017-02-27T10:54:03.507-08:00

Hi,        One of my customers wants me to design a login form (600 x 400) and display it in the centre of the windows desktop screen so that the browser is not visible at all. ( ie no menubars , address bars , status bars etc) . I have tried the foll code in the load_complete event of the form without success ScriptManager.RegisterStartupScript(Me.Page, Me.GetType(), "Script", "", False) All the browser bars still show Please help regards Sanjish [...]



linq vs linq to sql

2017-02-27T13:09:24.653-08:00

Is there any difference between linq vs Linq to sql?somebody asked me the question in interview.




Transactions Using Net Core and Repository Pattern (ADO .NET)

2017-02-24T16:16:44.36-08:00

Hello, I have a "webapi" in "Net Core" and I am using "Ado net" and "repository pattern".

My question is, if the repository is

public interface IRepository where T : BaseEntity
    {
        int Add(T item);
        void Remove(int id);
        int Update(T item);
        T FindById(int id);
        IEnumerable FindAll();
        //IEnumerable FindAll(T item);
    }

How can I have a transaction between the methods?

I want to have a transaction where it's called

Int Add (object1 item);

Int Add (object2 item);

Commit ();

I see that transactionscope is not for net core, how can I solve that case?




Getting Selected Index from Dropdownlist

2017-02-27T08:43:01.243-08:00

Good Day All, Please i need to get the selected Index of my dropdownlist, so that i can pass it to a model field, since its not saving because of that error This is my model: public class Product { public int ProductId { get; set; } [Required] public string ProductName { get; set; } [Required] public string ProductDescription { get; set; } [Required] public decimal Price { get; set; } public bool IsActive { get; set; } public bool IsDelete { get; set; } public DateTime CreatedDate { get; set; } public DateTime ModifiedDate { get; set; } [Required] public string ProductImage { get; set; } public bool IsFeatured { get; set; } [Required] public Category ProductCategory { get; set; } public IEnumerable ProductCategories { get; set; } } This is my View: @using (Html.BeginForm()) { @Html.AntiForgeryToken()

Product


@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.ProductCategory, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.DropDownListFor(model => model.ProductCategory, Model.ProductCategories, "Select Category...", new { @class = "form-control" }) @Html.ValidationMessageFor(model => model.ProductCategory, "", new { @class = "text-danger"})
@Html.LabelFor(model => model.ProductName, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.EditorFor(model => model.ProductName, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.ProductName, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.ProductDescription, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.EditorFor(model => model.ProductDescription, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.ProductDescription, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.Price, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.EditorFor(model => model.Price, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Price, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.IsActive, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.EditorFor(model => model.IsActive) @Html.Validatio[...]



How to load contents correctly, without seeing it expand in slow motion?

2017-02-24T16:23:19.063-08:00

That is what I have right now. Whenever the page is loaded after a postback, the contents will slowly inch towards their destinations. How do you prevent this from happening? Page_Load and SubmitButton_Click (callback function after the user clicks on the Submit button) both may be the culprit: Page_Load: protected void Page_Load(object sender, EventArgs e) { Debug.Write("Page_Load: "); if (!this.IsPostBack) { Debug.WriteLine("This is not a postback"); if (!Page.ClientScript.IsClientScriptIncludeRegistered("headTestScript")) { Page.ClientScript.RegisterClientScriptInclude("headTestScript", "Scripts/headTest"); } } else { Debug.WriteLine("This is a postback"); string threadListControlName = "threadListSection"; if (HttpContext.Current.Session[threadListControlName] == null) { HtmlControl tempControl = this.FindControlById(this, threadListControlName); if (tempControl != null) { HttpContext.Current.Session[threadListControlName] = tempControl; this.threadList = tempControl; Debug.WriteLine("SAFE: Thread List found."); this.threadList.Controls.Add(this.orderedThreadList); } else Debug.WriteLine("ERROR: Thread List not found."); } else { this.threadList = HttpContext.Current.Session[threadListControlName] as HtmlControl; Debug.WriteLine("SAFE: Thread List found."); } } } SubmitButton_Click: protected void SubmitButton_Click(object sender, EventArgs e) { Button clickedButton = sender as Button; if (clickedButton == null) return; switch (clickedButton.ID) { case "submitButton": Debug.WriteLine("This button is hitting correctly."); string html = ""; HtmlGenericControl listItem = new HtmlGenericControl("li"); listItem.Attributes.Add("class", "listBlock"); listItem.Style.Add("vertical-align", "middle"); listItem.Style.Add("width", "100%"); html += SingletonForum.Instance.CreateThread(this.titleBox.Text, this.bodyBox.Text); listItem.InnerHtml = html; string threadListName = "threadList"; this.orderedThreadList = HttpContext.Current.Session[threadListName] as HtmlGenericControl; this.orderedThreadList.Controls.Add(listItem); HtmlControl tempControl = this.FindControlById(this, "threadListSection"); if (tempControl != null) { tempControl.Controls.Clear(); tempControl.Controls.Add(this.orderedThreadList); } break; } } Full Code, just in case: using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Threading; using System.Web.UI.HtmlControls; namespace asp_practice { public partial class Default : System.Web.UI.Page { private HtmlGenericControl orderedThreadList; private HtmlControl threadList; private HtmlControl FindControlById(Control control, string id) { foreach (Control child in control.Controls) { if (child.ID != null && child.ID.Equals(id) && child is HtmlControl) { return (HtmlControl) child; } if (child.HasControls()) { HtmlControl result = this.FindControlById(child, id); if (result != null) return result; } } return null; } public void Application_Start(object s, EventArgs e) { Debug.Write("Application_Start: "); Application["startMessage"] = "Application has started."; } public void Application[...]



Inserting Blanks data into table using import to xl in ASP.NET C#

2017-02-24T06:37:39.52-08:00

Below is Button click code for import XL data to sql table using C# asp.net c#   protected void btn_bulkupload_PositionInfo_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); string status = string.Empty; string sWorkbook = "[Sheet1$]"; string Status = string.Empty; string Count = string.Empty; string root = Request.ServerVariables["APPL_PHYSICAL_PATH"] + "Data\\Contact_Master_Data"; if (FileUpload_PositionInfo.PostedFile.ContentLength > 0) { string s1 = FileUpload_PositionInfo.PostedFile.FileName; int pos = s1.LastIndexOf('\\') + 1; string s2 = s1.Substring(pos); string filename = GetRandomPasswordUsingGUID(8) + ".xls"; string filename1 = GetRandomPasswordUsingGUID(8); string filepath = Request.ServerVariables["APPL_PHYSICAL_PATH"] + "Contact_Master_Data\\/" + filename; FileUpload_PositionInfo.PostedFile.SaveAs(filepath); string sExcelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";Extended Properties='Excel 8.0;HDR=YES';"; // string sExcelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filepath + ";Extended Properties='Excel 12.0;HDR=YES';"; OleDbConnection OleDbConn = new OleDbConnection(sExcelConnectionString); try { string query = "SELECT * FROM " + sWorkbook; OleDbCommand OleDbCmd = new OleDbCommand(query, OleDbConn); OleDbConn.Open(); OleDbDataReader odr = OleDbCmd.ExecuteReader(); //string BatchId = string.Empty, CandidateName = string.Empty, LoginId = string.Empty, Password = string.Empty; while (odr.Read()) { if (odr[0].ToString() != "") { // bo.Dateused = DateTime.ParseExact(odr[0].ToString(), "MM/dd/yyyy", CultureInfo.InvariantCulture);//ReceivedDate // this.Text = "22/11/2009"; bo.Dateused = DateTime.ParseExact(odr[0].ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture); } else { string defaultdate = "01/01/1900"; bo.Dateused = DateTime.ParseExact(defaultdate.ToString(), "MM/dd/yyyy", CultureInfo.InvariantCulture);//ReceivedDate } bo.Para1 = odr[1].ToString();//Year bo.Para2 = odr[2].ToString();//Company bo.Para3 = odr[3].ToString();//ContactPerson bo.Para4 = odr[4].ToString();//Designation bo.Para5 = odr[5].ToString();//Role bo.Para6 = odr[6].ToString();//DesignationLevel bo.Para7 = odr[7].ToString();//Landline bo.Para8 = odr[8].ToString();//Mobile bo.Para9 = odr[9].ToString();//Email bo.Para10 = odr[10].ToString();//Address bo.Para11 = odr[11].ToString();//Location bo.Para12 = odr[12].ToString();//State bo.Para13 = odr[13].ToString();//Website bo.Para14 = odr[14].ToString();//SourceContact bo.Para15 = odr[15].ToString();//SourceType bo.Para16 = filename1;//File Name bo.Para17 = Session["EmailId"].ToString();//Sessoin Emailid bo.Para18 = this.Page.Request.ServerVariables["REMOTE_ADDR"]; bl.Admin_Insert_Bulk_Contact_Pre[...]



How to use PIVOT in SQL

2017-02-27T12:43:53.227-08:00

I have table data like this.

MasterNo SerialNo Position
140EE1 140EE1 1
140EE1 140EE2 2
140EE1 140EE3 3
140EE4 140EE4 1
140EE4 140EE5 2
140EE4 140EE6 3

I want result set like below

MasterNo Position1 Position2 Position3
140EE1 140EE1 140EE2 140EE3
140EE4 140EE4 140EE5 140EE6

Can anyone help me out??




Update with Parameters

2017-02-27T12:31:24.457-08:00

I have a sqldatasource with a select and update with parameters.  The update does not happen.  Permissions are correct at the table level. What am I doing wrong?  I have double checked variables and all appear to be correct. how to make this treeview style as the one in the image with checkboxes

2017-02-27T12:41:10.047-08:00

Hello all

I have a treeview strucure which I want it to appear as shown in pic (like arrow) on the side but with checkboxes too....how do I modify it?


    
    
    
    
           

(image)




Page_Load run twice

2017-02-20T09:05:04.693-08:00

Hi,

I have been dealing with the wirdest problem and I have just managed to realize what's causing it. The problem is I have no idea how to fix it.

I have a .net 4.5 web application and I am using VS2013.

When I run it for the first time, The Page_Load even fires twice.

I started debugging by creating a new solution and adding all pages and projects one by one.

Everything workes fine until I add a web setup project. 

It affects the application logic and I can't really release it this way.

Did anyone ever run into this problem? Or maybe does anyone has a suggestion on how to fix this?

Thanks!




Download dynamic data from datareader c# mvc

2017-02-25T21:12:45.72-08:00

Trying to get the  datareader columns and rows downloaded where the query will always be dynamic. No view is needed just needs to directly download to excel. 

  GridView gridview = new GridView();
                gridview.DataSource = result.ToList();
                gridview.DataBind();
                 Response.ClearContent();
                 Response.Buffer = true;
                 Response.AddHeader("content-disposition", "attachment; filename=DemoExcel.xls");
                // Response.AddHeader("Content-Type", "application/vnd.ms-excel");

    Response.Charset = "";

    // If you want the option to open the Excel file without saving than

    // comment out the line below

    // Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.ContentType = "application/ms.excel";
    StringWriter sw = new StringWriter();
    HtmlTextWriter htw = new HtmlTextWriter(sw);

    gridview.RenderControl(htw);

    Response.Output.Write(sw.ToString());
    Response.Flush();
    Response.End();

This is not working nothing happens please advise