|
It sounds like your headers are sent to IE7 compatibility.
Check the template page (your index.html/aspx/whatever) and make sure that the compatibility header is set correctly. For instance, for IE 9:
<head>
...
<meta http-equiv="X-UA-Compatible" content="IE=9" />
...
</head>
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Hi,
I also use this meta header name. But no use.
|
|
|
|
|
You did not say what the problem is !
|
|
|
|
|
Hi,
My problem is IE default version are automatically changed IE Edge to IE 7. But I want IE default version 9. How to changed default version of IE 9?
|
|
|
|
|
CAn you post your Meta tags.
|
|
|
|
|
|
You need to check few things here. If your application does not set to IE7 deliberately then why would browsers change to IE7, which means you dont have to set the compatibility meta tag at all.
It raises the second question which is by setting the meta tag to IE9 why wouldn't browers obey it.
My answer to the first question is, can you please check that your application doesn't alter browser's default beahviour deliberately.
Answer to the second question is that check your web.config and make sure that the correct meta tag is passed to the pages. Also check the 'view source' HTML in the browser rather than taking it from your source code.
Hope this helps.
|
|
|
|
|
I'm new to ASP, but not c#.
The fileupload control seems to be different than the rest of my controls, I cannot seem to link it to my c# code.
Do I need to create an event listener for it? Or a background worker process thread to monitor something from it?
I'm sure this is caused by me not understanding how the html and c# code work. How can I communicate between the fileupload control and my c sharp code in the background? I tried to put a javascript function into the head portion but it does not appear to be called and when I put a break point in there to test it, it does not hit the break point.
Thanks
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="True"
CodeBehind="Default.aspx.cs" Inherits="exchangePictureUpdater.exchangePictureUpdater" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script src="jquery-2.2.4.js"></script>
<script>
function loadimage() {
alert($("#thefile").prop('files'));
}
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#imgBox')
.attr('src', e.target.result)
<%--.width(150)
.height(200); --%>
$("#<%=tbxPictureHeight.ClientID %>").val("");
$("#<%=tbxPictureWidth.ClientID %>").val("");
$("#<%=tbxPictureFileSize.ClientID %>").val("");
$('#imgBox').on('load', function () {
var height = this.naturalHeight,
width = this.naturalWidth;
$("#<%=tbxPictureHeight.ClientID %>").val(height);
$("#<%=tbxPictureWidth.ClientID %>").val(width);
var imgpath = document.getElementById('theFile');
//if (!imgpath.value==""){
//var img=imgpath.files[0].size;
//var imgsize=img/1024;
//alert(imgsize);
//$("#<%=tbxPictureFileSize.ClientID %>").val(imgsize);
});
};
reader.readAsDataURL(input.files[0]);
}
}
//function btnAddReplace_Click() {
// alert($("#imgBox").prop('src'));
//}
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:Button ID="btnResolvePin" runat="server" Height="29px" Text="Resolve Pin" Width="160px" OnClick="btnResolvePin_Click" />
<asp:TextBox ID="tbxPinName" runat="server"></asp:TextBox>
<asp:DropDownList ID="ddlDomains" runat="server">
<asp:ListItem Value="1"></asp:ListItem>
<asp:ListItem Value="2"></asp:ListItem>
<asp:ListItem Value="3"></asp:ListItem>
<asp:ListItem Value="4"></asp:ListItem>
<asp:ListItem Value="5"></asp:ListItem>
<asp:ListItem Value="6"></asp:ListItem>
<asp:ListItem Value="7"></asp:ListItem>
<asp:ListItem Value="8"></asp:ListItem>
</asp:DropDownList>
<br />
<asp:Label ID="lblUserResolvedName" runat="server" Text="User Resolved Name"></asp:Label>
<asp:TextBox ID="tbxUserName" runat="server" ReadOnly="True" Width="354px"></asp:TextBox>
<asp:Button ID="btnTest" runat="server" Height="29px" OnClick="btnTest_Click" Text="Test" />
<br />
<br />
<asp:Label ID="lblBrowseForPicture" runat="server" Text="Browse For Picture"></asp:Label>
<asp:Label ID="lblPictureHeight" runat="server" Text="Picture Height"></asp:Label>
<asp:Label ID="lblPictureWidth" runat="server" Text="Picture Width"></asp:Label>
<asp:Label ID="lblPictureFileSize" runat="server" Text="File Size"></asp:Label>
<br />
<asp:FileUpload ID="thefile" runat="server" onchange="readURL(this);" itemid="thefile" value="thefile" Width="347px" />
<asp:TextBox ID="tbxPictureHeight" runat="server" ReadOnly="True" Width="70px"></asp:TextBox>
<asp:TextBox ID="tbxPictureWidth" runat="server" ReadOnly="True" Width="70px"></asp:TextBox>
<asp:TextBox ID="tbxPictureFileSize" runat="server" ReadOnly="True" Width="70px"></asp:TextBox>
<asp:Label ID="lblPictureFileSizeInKBs" runat="server" Text="KB's"></asp:Label>
<br />
<br />
<asp:Button ID="btnViewPicture" runat="server" Height="29px" OnClick="btnViewPicture_Click" Text="View Picture" Width="160px" />
<br />
<br />
<asp:Button ID="aspbtnAddReplace" runat="server" Height="29px" OnClick="btnAddReplace_Click" text="Add/Replace Picture" Width="160px" />
<br />
<br />
<asp:Button ID="btnDelete" runat="server" Height="29px" OnClick="btnDelete_Click" Text="Delete Picture" Width="160px" />
<br />
<br />
<asp:Button ID="btnSavePicture" runat="server" Height="29px" OnClick="btnSavePicture_Click" Text="Save Picture" Width="160px" />
<br />
<br />
<asp:Button ID="btnClearPicture" runat="server" Height="29px" OnClick="btnClearPicture_Click" Text="Clear Picture" Width="160px" />
<br />
<br />
<asp:Image ID="imgBox" runat="server" ImageUrl='<%# "data:image/jpg;base64," + Convert.ToBase64String((byte[])Eval("IMG_DATA")) %>' />
<asp:Panel ID="DialogControl" Visible="false" runat="server" style="position:absolute;width:200px;height:150px;top:200px;right:300px;border:thick;z-index:100" BackColor="Red" BorderColor="Black" BorderStyle="Solid" BorderWidth="5px">
<asp:Literal ID="DialogContent" runat="server"></asp:Literal><br />
<asp:Panel id="buttonpanel" runat="server" style="text-align: center; position:relative;" Height="100%" Width="100%" BackColor="Red" >
<asp:Button ID="DialogOKButton" runat="server" Text="OK" OnClick="DialogOKButton_Click" style="text-align: center; position: absolute; bottom:0;"/>
</asp:Panel>
</asp:Panel>
</asp:Content>
|
|
|
|
|
To the best of my knowledge, you just listen for the file upload event.
In MVC, I wrote a new way of uploading a file, or multiple files at the same time.
I used JQuery to listen for the DOM event "change"; file upload button, and ran a JQuery function to intercept the upload and target the data to a JsonResult in one of my controllers, an Ajax controller.
Sounds weird huh?. But I will show 2 examples, MVC and Webforms. I believe this is the secret to Uploadify.
JQuery: in the document ready, I listened for the upload button to fire an event to upload the file stream, which is just a base64 string representing bytes. So this validates the name of the files, and then runs the function
$("#AvatarBrowse").on("change", function (e) {
if (validate_upload_brandAvatar()) {
run_upload_brandAvatar(e, $(this));
}
});
JQuery: This intercepts the file upload, but passes extra data along with the page event.
var _extraData = "?id=-1&avatarName=" + _avatarName + "&avatarAlt=" + _avatarAlt;
if (window.FormData !== undefined) {
var _data = new FormData();
for (var x = 0; x < _files.length; x++) {
_data.append("file" + x, _files[x]);
}
$.ajax({
type: "POST",
url: '/Ajax/json_upload_brand_avatar' + _extraData,
contentType: false,
processData: false,
data: _data,
Then in my Ajax Controller, its an Async Task<<JsonResult>>
This grabs the file content in the base64 string of bytes, and converts the string to a byte array to save in the database. Then it processes the image, and sends back a base64 string of the image to preview after changes.
var fileContent = Request.Files[file];
if (fileContent != null && fileContent.ContentLength > 0)
{
using (MemoryStream stream_in = new MemoryStream())
{
fileContent.InputStream.CopyTo(stream_in);
string oFileName = fileContent.FileName;
string oFileExt = Path.GetExtension(oFileName);
string fileName = cleanInput.Clean_FileName(avatarName.ToLower() + oFileExt);
var path = Path.Combine(Server.MapPath("~/Images/avatars/departments"), fileName);
On webforms, it's a different process.
you use the IHTTPHandler and ProcessRequest to intercept the file upload. I wrote this in VB, I just started writing in c#. This uses uploadify to upload the file, and the function below intercepts the upload from the browser, captures the post to the server.
Public Class Admin_Management_ckEditor_Upload
Inherits System.Web.UI.Page
Implements IHttpHandler
Implements IRequiresSessionState
Public Overrides Sub ProcessRequest(ByVal context As HttpContext)
Dim Exception_Message As String = Nothing
Try
Dim vFlag As Boolean = False
Dim m_Context As HttpContext = HttpContext.Current
Dim m_file As HttpPostedFile = m_Context.Request.Files("upload")
If Not (m_file Is Nothing) Then
'Get the Uploaded file information from the file object
Dim m_fileName As String = m_file.FileName
Dim m_fileSize As Integer = m_file.ContentLength
Dim m_fileContent As String = m_file.ContentType
Basically in a nut shell, the browser will post the file to the server, you just need something to intercept the post and do something with it. I find once again that MVC is much more easier to work with and requires much less code.
Knowing now that the upload is just a base64 string of bytes, it's much easier for me to comprehend what is happening, and turn that string of bytes into a byte array to save in the database or to write out as a file. I choose to funnel that byte array into an image processor that I wrote, posted in a previous post here, to further process the image and return the byte array back, using my Ajax controller function. I sent it back as a base64 string to the page so the processed image can be previewed and saved.
I don't expect you to just pick on this and run with it, but its enough information for you to search in the right direction towards your goal. I don't remember a simpler way of doing it anymore. It's one of those things that you write once and keep using over and over.
|
|
|
|
|
You don't have any c# code that is interacting with the file upload so you might need to explain your problem better, and maybe be more explicit about the language you use, eg javascript isn't c#, are you trying to interact on the client or the server, and so on.
|
|
|
|
|
Dear All,
Can you please suggest me how to open specific url in Chrome Browser from asp.net Iframe.
|
|
|
|
|
Erm...
<iframe src="specific.address.com">
You need IFrames enabled to view this content
</iframe>
Just a thought.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
You can't dictate or control what browser your files are opened in. It will be opened in whatever browser the user chooses to view your page. If your page only works in chrome then you have to fix your code such that it works on all browsers.
|
|
|
|
|
From the question you have asked and the answers given , you haven't explained your problem well enough. Can you please with little more details.
|
|
|
|
|
how to get latitude and logitude from sql server 2008 ,Asp.net web form
how to conncet sql server 2008?
i want to get title, latitude ,logitude and description from sql server 2008?
please guide me . i am new and not good in programming??
i have created data base in SQL Server 2008.table name is UolMap.i have also enter some data in table ..
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="gmap.ascx.cs" Inherits="line.usercontrol.GMap" %>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
var markers = [
{
"title": "University",
"lat": 43.9801363,
"lng": 81.4439812,
"description": "University"
},
{
"title": "School",
"lat": 38.4887684,
"lng": 78.3207063,
"description": "School"
}
];
var mapOptions = {
center: new google.maps.LatLng(33.375321, 99.345116),
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var infoWindow = new google.maps.InfoWindow();
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
for (i = 0; i < markers.length; i++) {
var data = markers[i]
var myLatlng = new google.maps.LatLng(data.lat, data.lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: data.title
});
(function (marker, data) {
google.maps.event.addListener(marker, "click", function (e) {
infoWindow.setContent(data.description);
infoWindow.open(map, marker);
});
})(marker, data);
}
}
</script>
<body onload="initialize()">
<div id="map_canvas" style="width: 1150px; height: 450px">
</div>
</body>
modified 16-Jun-16 7:47am.
|
|
|
|
|
Hi All,
please helt me to with code example...
i can't understand how to load latitude and longitude from database and show a related location and marker on GOOGLE MAP in my web form...
how to conncet sql server 2008?
i want to get title, latitude ,logitude and description from sql server 2008?
thanks for help...
|
|
|
|
|
I have a couple of ASP.NET web pages; the first page does a cross-page postback to the second. This second page has an AJAX update panel. The second page has a server-side button outside the update panel. The button runs JavaScript (onclientclick) to close the page and open the calling page, and it functions properly when the button is clicked. When I take some other action on page 2 that triggers an AJAX call, the JavaScript triggers, closes the page, and returns to the calling page. I changed the button to a server-side linkbutton with the same JavaScript and now the page behaves as it should.
Is this one of the bad characteristics of the update panel?
|
|
|
|
|
server side controls just write HTML for you. In the time it takes to write a server control on the page, you could have just written plain HTML.
You really need to look at the page source and look at the HTML that was written between the 2 server controls, button and link button. Since I cant see the page and examine the HTML, I cannot do any forensics on it.
In the update panel, you can assign async postback triggers for a button to fire the assigned server function in a partial post back, in which a small round trip of the HTML inside the update panel is sent to the server as a partial post back, and HTML is sent back and replaced on the page within that container.
You may of just made a mistake onClientClick, it should return false to stop a post back event.
eg. onClientClick = "returnUrl(); return false;"
I stopped using update panels over 6 years ago, because they were buggy and unreliable in terms of speed during a full load on the internet connection or distance; say across the country, and the user would always misinterpret the situation. I got way better at planning or engineering forms after that, just using jQuery or JavaScript to complete the task, or just do a full post back to the server.
In fact better yet, I stopped using web forms completely and went MVC to produce much better work faster with higher quality.
|
|
|
|
|
Thank you for your prompt response. I have been advised before to move to MVC with Razor. But I am too old to redo my site. Thus far I have been able to work around problems like this one; but I am always curious about the cause. I went to an update panel to avoid page jump back to the top on postback. If there is a simple way to avoid this, I would certainly look into it.
I am looking at movint to jquery and HTML5.
|
|
|
|
|
Generally I find web forms are "okay" when you're using the old-school postback model, but struggle greatly when it comes to handling AJAX. This is generally because the framework tries to hide the execution context from the developer, and UpdatePanels are about the worst offenders.
I quickly replace any web forms application that is put in my care with a .NET MVC or a JavaScript SPA, depending on scale and needs. Just the maintenance problems alone warrant it, IMO.
You're not going to get away from the client-vs-server side issues as long as you're using web forms.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Nathan,
Thank you for your advice. Is there any tool that can convert web pages to MVC? Or, do I need to build from scratch? I don't use any data handling on the pages except for login control. All of the pages gather input and present calculation results from VB code behind. Are these pages still usable in an MVC project? So far, it all still works. I'll have to have someone from China check the speed. I use Godaddy hosting. These servers may be in Australia.
|
|
|
|
|
Honestly if it all still works I'd be surprised if you got any management support for re-coding the project. There are no tools that I'm aware of that will effectively parse out web forms into .NET MVC.
I would assume up front than anything you write in .NET MVC will need to be fresh code, but can be informed by the business rules of pre-existing web forms applications.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Nathan,
Thanks for your affirmation. With the pace of change to web development things might look quite different in a couple years. So it seems that there is no easy transition. And you are right about convincing management. Because that is me, and I am also the owner. I built the site 10 years ago and have progressively upgraded content and function. This is a hobby, and so far some of the applications are free. But not the best stuff, which requires a subscription. I think what I will do is wait until the site no longer functions with developing technology. At that point, depending on when it comes, I'll move the applications to a cloud. Everything that is on the site I also have a desktop windows form application. I think that this can be served to clients securely so that the apps cannot be copied and distributed at will. My current project is to use SQLight with some of my applications that now use MS Access. But it seems that Microsoft doesn't play nicely with it. Sometimes it works; sometimes not.
|
|
|
|
|
Hi All,
I am trying to call an action method on a button click, I am trying to create and declare my button as below, basically it is in the Index.cshtml page or View from there I want to redirect my page to the "CreateUser.cshtml", my Controller name is "UserController" and my Action method is "CreateUser".
My Controllers are in Controllers folder and My user related Views are in "\Views\User" folder under root folder
<input type="button" value="Create User" onclick="location.href='@Url.Action("Create", "User")'" />
And my View where the button is there is:
@model MVCWithWebApiApp.Models.User
@{
ViewBag.Title = "Index";
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Users Details</title>
<script src="~/Scripts/jquery-2.2.4.min.js"></script>
<script src="~/Scripts/angular.min.js"></script>
<script src="~/Scripts/myApp.js"></script>
</head>
<body>
<h2>Index</h2>
<div data-ng-app="myApp" data-ng-controller="userController">
<table style="border:none 0px gray;">
<tr>
<td>
<table style="border:solid 1px gray;">
<tr>
<td style="border:solid 1px gray;">User Id</td>
<td style="border:solid 1px gray;">User Name</td><br />
</tr>
<tr data-ng-repeat="usr in users">
<td>{{usr.UserId}}</td>
<td>{{usr.UserName}}</td><br />
</tr>
</table>
<pre>
</td>
<td>
<input type="button" value="Create User" onclick="location.href='@Url.Action("Create", "User")'" />
</td>
</tr>
</table>
</div>
And Controller is:
<pre>
public class UserController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult GetUsers()
{
var dbContext = new MVCDBContext();
List<User> listOfUsers;
listOfUsers = dbContext.Users.ToList();
return Json(listOfUsers, JsonRequestBehavior.AllowGet);
}
public ActionResult Details(int id)
{
return View();
}
public ActionResult CreateUser()
{
return View();
}
[HttpPost]
public ActionResult CreateUser(FormCollection collection)
{
try
{
var dbContext = new MVCDBContext();
User user = new User();
user.UserId = 1;
user.UserName = "Abdul";
dbContext.Users.Add(user);
dbContext.SaveChanges();
return RedirectToAction("Index");
}
catch
{
return View();
}
}
public ActionResult UpdateUser(int id)
{
return View();<br />
}
[HttpPost]
public ActionResult UpdateUser(int id, FormCollection collection)
{
try
{
var dbContext = new MVCDBContext();
User user = new User();
user.UserId = 1;
user.UserName = "Abdul";
user = dbContext.Users.Where(i => i.UserId == 1).FirstOrDefault();
user.UserName = "Abdul Aleem";
dbContext.SaveChanges();
return RedirectToAction("Index");
}
catch
{
return View();
}
}
public ActionResult DeleteUser(int id)
{
return View();
}
[HttpPost]
public ActionResult DeleteUser(int id, FormCollection collection)
{
try
{
var dbContext = new MVCDBContext();
User user = new User();
IQueryable<User> Users = dbContext.Users.Where(i => i.UserId == 1);
foreach (User a in Users)
{
dbContext.Users.Remove(a);
}
dbContext.SaveChanges();
return RedirectToAction("Index");
}
catch
{
return View();
}
}
}
And Web.config within View Folder is:
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.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.Optimization"/>
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<pre>
<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
<system.webserver>
<validation validateintegratedmodeconfiguration=""false"">
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
Not only the @Url my View is giving error at @model that model doesn't exist and saying ViewBag doesn't exist.
If you need my model
namespace MVCWithWebApiApp.Models
{
public class User
{
private int _userId;
public int UserId
{
get { return _userId; }
set { _userId = value; }
}
private string _userName;
public string UserName
{
get { return _userName; }
set { _userName = value; }
}
}
}
Please help me I am new to ASP.Net MVC
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
modified 14-Jun-16 16:49pm.
|
|
|
|
|
Well you can use a Razor Html Helper
ActionLink to make a button
@Html.ActionLink("Create User", "Create", "User", new { userID = "-1"] }, new { @class = "btn btn-default" })
Or an A element using Url.Action for the href, then change the class to make it look like an button.
<a class="btn btn-default" href="@Url.Action("Create", "User", new { userID = "-1" })" data-toggle="tooltip" data-placement="bottom" title="Create User" data-original-title="Create User">Create User</a>
I did look at your code. You need to create a model in the controller actionresult "Create" and return it in the view, so the page has a model to work with.
|
|
|
|
|