|
 Is there any way that a reference to the master page can be setup uniquely for a single web page? If so, how would you setup that code?
Here is the code I am thinking you wanted to see:
Imports System.Data
Imports System.Reflection
Imports System.Windows.Forms
Imports Telerik.Web.UI
Imports System.Web.Script.Services
Imports System.Web.Script.Serialization
Imports System.Web.Services
Partial Class attendanceletters_default
Inherits System.Web.UI.Page
Protected _master As MasterPage
Protected _schoolyear As Integer
#Region "Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load"
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
_master = CType(Page.Master, MasterPage)
_master.PageTitle = "Attendance"
Dim schoolDate As DateTime = Today()
Dim schoolMonth As Integer = schoolDate.Month
Dim schoolYear As Integer = schoolDate.Year
If schoolMonth >= 8 And schoolMonth <= 12 Then
_schoolyear = schoolDate.AddYears(1).Year
ElseIf schoolMonth >= 1 And schoolMonth <= 7 Then
_schoolyear = schoolDate.AddYears(0).Year
End If
If Request.UrlReferrer IsNot Nothing Then
SiteUserManager.SessionUser.SiteUri = Request.UrlReferrer
End If
If Not Page.IsPostBack Then
If (SiteUserManager.SessionUser IsNot Nothing) Then
LoadSchools()
If ddlSchools.SelectedValue <> "" Then
LoadMilestones(ddlSchools.SelectedValue)
GetGrdiviewData()
End If
End If
End If
Response.Cache.SetExpires(DateTime.Now())
Response.Cache.SetCacheability(HttpCacheability.NoCache)
End Sub
#End Region
|
|
|
|
|
Yes you can assign a different master page to a specific page programmatically.
|
|
|
|
|
In a vb.net 2010 webform application, I am going to display a popup javascript alert message for the user when there are 2 records in the database for the current school year for each unique student. This popup message is displayed since the user needs to update the database using vendor software.
For the javacript alert message, I have the following questions:
1. At the top the alert message, it says 'Message from Web Page' since that is probably the default value. Is there a way that I can change this message to something I want? If so, how can I change the message?
2. I am wondering what if there maximum length that I can display in the error message? If so, what is the maximum length?
3. Can I extend the maximum size of the message and if so, can you show me how to extend the size of the error message?
4. Can I change the display icon to be an error instead of a warning? If so, how would I accomplish this goal?
|
|
|
|
|
|
1 No
2 & 3 None but if the message gets too big it is unreadable
4 No
Alert has no real use outside of debugging, if you want to show a "popup" or modal message then look at a jQuery plug-in for it. jQuery UI comes with one but there are many others if you google "jquery modal plug-in".
|
|
|
|
|
OK, WTF is going on here?
Your question is an exact copy of this other question[^], posted by a different user.
At first I thought yours was the original, since the other message looks like it's been copied from somewhere. Then I checked the timestamp - your message was posted eight hours after the other copy.
If you own both accounts, then one or both is a "sock-puppet" account, which is considered abuse.
If you don't, then you've reposted someone else's question, which is also abuse.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
And he's been doing this for nearly five years.
|
|
|
|
|
|
I have this report to write, it's content is company information and then sales numbers for months for 5 years below the company information
eg.
ABC Company John 714-555-1212 ATD: $1.00 Balance: $0.00
Year Jan Feb March
2016 $1.00 $2.00 $3.00
2015 $2.00 $1.00 $5.00
2014 $3.00 $2.00 $1.00
So I'm using Dataset and DataTable to build the data
I created 2 tables
Dim rs_CR As DataTable = New DataTable()
rs_CR.TableName = "dt_customerRecords"
rs_CR.Columns.Add(New DataColumn("ID", System.Type.GetType("System.String")))
rs_CR.Columns.Add(New DataColumn("Name", System.Type.GetType("System.String")))
rs_CR.Columns.Add(New DataColumn("FName", System.Type.GetType("System.String")))
rs_CR.Columns.Add(New DataColumn("LName", System.Type.GetType("System.String")))
rs_CR.Columns.Add(New DataColumn("Phone", System.Type.GetType("System.String")))
rs_CR.Columns.Add(New DataColumn("Fax", System.Type.GetType("System.String")))
rs_CR.Columns.Add(New DataColumn("ATD", System.Type.GetType("System.Decimal")))
rs_CR.Columns.Add(New DataColumn("Balance", System.Type.GetType("System.Decimal")))
I want to add another something here to join the table below. In the RDLC using a Tablix, I can only have 1 dataset. If I create 2 datasets, the dataset prints after the data above, and is not part of the set above.
Dim rs_RP As DataTable = New DataTable()
rs_RP.TableName = "dt_reportData"
rs_RP.Columns.Add(New DataColumn("Year", System.Type.GetType("System.Int32")))
rs_RP.Columns.Add(New DataColumn("P1", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P2", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P3", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P4", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P5", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P6", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P7", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P8", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P9", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P10", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P11", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P12", System.Type.GetType("System.Decimal")))
Dim ds_CR As DataSet = New DataSet()
ds_CR.DataSetName = "ds_customerRecords"
ds_CR.Tables.Clear()
ds_CR.Tables.Add(rs_CR)
ds_CR.Tables(0).TableName = "tablix_customerRecords"
rv_Canvas.LocalReport.DataSources.Clear()
rv_Canvas.LocalReport.DataSources.Add(New ReportDataSource("ds_customerRecords", ds_CR.Tables(0)))
rv_Canvas.LocalReport.Refresh()
As a caveat, I'm getting the data from an old Foxpro database that is not quite SQL
|
|
|
|
|
Hi,
Please tell me the how to implement the pkcs in ASP.NET .
|
|
|
|
|
I would, but can't see the connection between ASP.NET and encryption...
System.Security.Cryptography.Pkcs Namespace[^]
(Google is your friend)
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
I have tried many steps like uninstall NuGet pakeged and than restart the Visual studio and than again i install the pakeges .
I have tried another solution which is
Press Windows + R
Enter appwiz.cpl and press Enter
Right-click the entry "Microsoft Visual Studio Express 2015 for Web" and click "Repair"
(This is going to reinstall all packages that you have uninstalled, because you weren't needing them (eg. Microsoft SQL Server Native Client)
|
|
|
|
|
You first need to identify which file it is not able to find.
|
|
|
|
|
how will i find that which file is a barrier in creating project , i mean from that particulre meesage how can i find , i just update the 2012 couple of days back and now this happend
|
|
|
|
|
Sorry but I do not know the answer, but I would expect more information to appear in the error message or some log entry to be made, either in the project directory or in the system event log.
|
|
|
|
|
In the title you are complain about 2012, but you show us that you run a repair on 2015!
How that connected? (2012 includes MVC4, so no need of 2015 for that)
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
brother i just told u the pattern, copy and paste from stack overflow
but i did as i required for 2012 so without making joke tell me the solution otherwise do ur work ok
|
|
|
|
|
You missed the point! I'm NOT your debugger - you have one built in in your VS!!!
With that attitude you will spend an eternity to solve such problems...
You want answers? Give details! We do not ask questions for nothing, but to help and clarify!!!
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
ok brother sorry dont mind . i had found the solution
|
|
|
|
|
Hello,
I have very perplexing issue. For years I have made websites with Asp.net and have used some lines of code to export gridview data to an excel work sheet. Last week the code just stopped working, I did not change anything with the code to any of the points in my website that exports to excel, it just stopped working.
I have tested it on both my development server and production server, same thing. It still pops up an excel link but when you open the excel file there is nothing, and it doesn't even generate a blank workbook.
Here is the code I use:
public static void DGToExcel(System.Web.UI.Control ctl)
{
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=Excel.xls");
HttpContext.Current.Response.Charset = "UTF-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
HttpContext.Current.Response.ContentType = "application/ms-excel";
// ctl.Page.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
I have absolutely no idea what is going on here and why code I have been using for years would stop working. If someone could shed some light on this issue I would grealt appreciate it. Thanks.
Marc
|
|
|
|
|
The thing is, you're NOT exporting the grid to an Excel file. You're sending an HTML document to the browser, but "lying" in the headers and telling it the response is an Excel document. Excel is then doing its best to convert the HTML into an Excel worksheet.
Not only does this limit your control over the formatting and prevent you from using any "advanced" features of Excel, it also leaves you subject to the whims of whatever version of Excel the user has installed. When you run into strange problems like this, there is often no obvious cause or workaround.
If you're lucky, you might be able to track it down to a recent security update, or a change to the users' settings. But telling your users to uninstall security updates just to get your code working again isn't a sensible option.
You'll probably have better luck if you change your code to create a real Excel file. Since you're using ASP.NET, you can't use Office Interop[^]. But there are several open-source libraries which are safe to use from server-side code:
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Okay I'm following you, I will look into those other options of creating an excel read file. I actually remember that's how I did it an a program I made many years ago but I have since lost that code.
Thank you very much for your reply.
|
|
|
|
|
In my Relation i have two tables relation (one to many)
table country
Id (primary key)
Countryname
table City
Id (primary key)
Cityname
Countryid (forign key)
I have controller City have the following function
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LinqProject.Models;
namespace LinqProject.Controllers
{
public class CityController : Controller
{
mytaskdbEntities db = new mytaskdbEntities();
public ActionResult List()
{
return View(db.Cities.ToList());
}
and in view of List as following
<body>
<div>
<table>
@foreach (var item in Model)
{
<tr><td>@item.Cityname</td><td>@item.Country.Countryname</td></tr>
}
</table>
</div>
</body>
What i need actually adding delete button to view of list of city
and i can delete city when click button delete
how to do deleting record by linq
the final result as following
USA NEWYORK DELETEBUTTON
USA WASHINTON DELETEBUTTON
FRANCE PARIS DELETEBUTTON
when click delete button for row USA NEWYORK it will delete
and remaining two record
USA WASHINTON DELETEBUTTON
FRANCE PARIS DELETEBUTTON
|
|
|
|
|
You can add button control with command 'delete' in the buttons. When you click pass the id of city to be deleted to the controller. In the controller you need to receive two parameters command and id of the city.
What's your issue ?
|
|
|
|
|
Is there any way to somehow combine the data from two models and THEN map them *both* to the same viewModel in the context of an edit action?
I have never had to update several tables at once in an edit action in ASP.NET MVC with Entity Framework 6.1.3. This is the layout:
I have a DB table called "Address" which has fields for StreetNumber, StreetName, City, State, ZipCode. It has a *one-to-one* relationship with another table called Bars. As in, a bar can only have one address and one address can only have one bar.
Because I am storing this data in two separate tables, I am having a very difficult time trying to successfully implement an Edit action which takes data from **one form** (BarForm) and should update both the Bar and Address database tables. See my code:
**BarController**
public ActionResult Edit(int id)
{
var bar = _context.Bars.SingleOrDefault(m => m.Id == id);
var address = _context.Addresses.SingleOrDefault(a => a.BarId == id);
if (bar == null)
{
return HttpNotFound();
}
var viewModel = Mapper.Map<Bar, BarFormViewModel>(bar, new BarFormViewModel());
if (address == null)
{
address = new Address();
}
Mapper.Map<Address, BarFormViewModel>(address, viewModel);
viewModel.IsNew = false;
return View("BarForm", viewModel);
}
[ValidateAntiForgeryToken]
public ActionResult Save(BarFormViewModel bar)
{
if (!ModelState.IsValid)
{
var viewModel = Mapper.Map<BarFormViewModel, BarFormViewModel>(bar, new BarFormViewModel());
viewModel.IsNew = false;
return View("BarForm", viewModel);
}
if (bar.Id == 0)
{
var newbar = Mapper.Map<BarFormViewModel, Bar>(bar);
newbar.LastUpdated = DateTime.UtcNow;
_context.Bars.Add(newbar);
var addressToAdd = Mapper.Map<BarFormViewModel, Address>(bar);
_context.Addresses.Add(addressToAdd);
}
else
{
var barInDb = _context.Bars.Single(b => b.Id == bar.Id);
var addressInDb = _context.Addresses.Single(a => a.BarId == bar.Id);
Mapper.Map<BarFormViewModel, Bar>(bar, barInDb);
Mapper.Map<BarFormViewModel, Address>(bar, addressInDb);
}
_context.SaveChanges();
return RedirectToAction("Index", "Bar");
}
**Domain Models:**
public class Bar
{
public int Id { get; set; }
public string Name { get; set; }
[Required]
public string GooglePlaceId { get; set; }
public string SundayDiscounts { get; set; }
public string MondayDiscounts { get; set; }
public string TuesdayDiscounts { get; set; }
public string WednesdayDiscounts { get; set; }
public string ThursdayDiscounts { get; set; }
public string FridayDiscounts { get; set; }
public string SaturdayDiscounts { get; set; }
[Display(Name = "Last Updated")]
public DateTime LastUpdated { get; set; }
}
public class Address
{
public int Id { get; set; }
public int? Number { get; set; }
public string StreetName { get; set; }
public string City { get; set; }
public string State { get; set; }
[Required]
public int ZipCode { get; set; }
public Bar Bar { get; set; }
public int BarId { get; set; }
}
**View Model which includes both Address and Bar properties**:
{
public class BarFormViewModel
{
public int? Id { get; set; }
public string Name { get; set; }
[Required]
[Display(Name = "Google Place ID")]
public string GooglePlaceId { get; set; }
[Display(Name = "Sunday Happy Hour Info:")]
public string SundayDiscounts { get; set; }
[Display(Name = "Monday Happy Hour Info:")]
public string MondayDiscounts { get; set; }
[Display(Name = "Tuesday Happy Hour Info:")]
public string TuesdayDiscounts { get; set; }
[Display(Name = "Wednesday Happy Hour Info:")]
public string WednesdayDiscounts { get; set; }
[Display(Name = "Thursday Happy Hour Info:")]
public string ThursdayDiscounts { get; set; }
[Display(Name = "Friday Happy Hour Info:")]
public string FridayDiscounts { get; set; }
[Display(Name = "Saturday Happy Hour Info:")]
public string SaturdayDiscounts { get; set; }
[Display(Name = "Last Updated")]
public DateTime? LastUpdated { get; set; }
public Address Address { get; set; }
public int? AddressId { get; set; }
[RegularExpression("([1-9][0-9]*)", ErrorMessage = "Must be a number")]
public int? Number { get; set; }
public string StreetName { get; set; }
public string City { get; set; }
public string State { get; set; }
[Required]
public int? ZipCode { get; set; }
public bool IsNew { get; set; }
}
The problem here is that I am getting an empty AddressId with this setup, which is causing an exception when the Save action gets run. This is because the BarForm view is getting passed a ViewModel which has been mapped from a Bar object and the Bar domain model actually has no Address information in it, since it is not the Address model/table.
Is there any way to somehow combine the data from both the Address and Bar models and THEN map them *both* to the same viewModel?
I keep getting a Sequence Contains no Elements error for this line in the Save action:
var addressInDb = _context.Addresses.Single(a => a.Id == bar.AddressId);
I also tried:
var addressInDb = _context.Addresses.Single(a => a.BarId == bar.Id);
Neither work. I understand what the error is saying and have also checked the actual HTML for my hidden Addressid field and it is blank... See code in my BarForm View:
@Html.HiddenFor(m => m.Id)
@Html.HiddenFor(m => m.AddressId)
@Html.AntiForgeryToken()
|
|
|
|
|