hi, i have a double, the decimal place isn't fix (8-?)
i want to fix the decimal place to six (for example: 1,234567).
this is my double:
CStr(score)
i guess it's quiet simple :P
Hi,
I am having SYBASE 12.5 install on my server as well as my PC, I am unable to get the correct connection string.
I have used the connectionstrings.com but unable to get the correct one.
After runnig and making the connection
Driver={Sybase ASE ODBC Driver};srvr=server_name;database=database_name;UID=user_name;PWD=pass;
and some other combination of thic connection string
I am getting the
Datasource =""
Driver =""
DataBase=""
ServerVersion = Invalid Operation. Connection is closed
What am I suppose to correct in that.
Please help.
Thanks
I have two textboxes and one Button control.....In first TextBox when press enter key moves to next textbox(Barcode) and when i press enter in barcode textbox it fires the button click event......till that its ok....
But what happening after fireing the Button click even on enter in Barcode Textbox its going back to focus on first textbox.........But i want this to stay in same Barcode TextBox to scan more barcodes.
The code is below.
<script type="text/javascript"
src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js">
</script>
<Head>
<script type="text/javascript">
$(function() {
$('input:text:first').focus();
var $inp = $('input:text');
$inp.bind('keydown', function(e) {
//var key = (e.keyCode ? e.keyCode : e.charCode);
var key = e.which;
if (key == 13) {
e.preventDefault();
var nxtIdx = $inp.index(this) + 1;
$(":input:text:eq(" + nxtIdx + ")").focus();
}
});
});
</script>
</Head>
Hi
I have a web application that fetches a lot of content via ajax. For example when a user edits some data, the browser will send the changes using an ajax post and then do an ajax get to get fresh content and replace an existing div on the page with that content. This was working just find with MVC1, but in MVC2 I would get inconsistent results.
I've found that MVC1 by default included an Expires item in the response headers set to the current time, but in MVC2 the Expires header is missing. This is a problem with some browsers (IE8) actually using the cached version of the ajax get instead of the fresh version.
To deal with the problem I created a simple ActionFilterAttribute that sets the reponse cache to NoCache (see below), which works, but it seems kind of sillly to decorate every controller with this attribute. Is there a global way to set this for every controller?
Is this a bug in MVC2 and it really should be setting the expires on every ActionResult/view/page? Don't most MVC programs deal with data entry where stale data is a very bad thing?
Thanks
Dan
public class ResponseNoCachingAttribute : ActionFilterAttribute
{
public override void OnResultExecuted(ResultExecutedContext filterContext) {
base.OnResultExecuted(filterContext);
filterContext.HttpContext.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
}
}
I am beginning to think I am doing something wrong. I mean they did place System.String.IsNullOrWhitespace finally but no ArgumentEmptyException class.
public FilterItem(string name, IEnumerable<string> extensions)
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentNullException("name");
}
if (extensions == null)
{
throw new ArgumentNullException("extensions");
}
if (extensions.Count() == 0)
{
throw new ArgumentOutOfRangeException("extensions");
}
this.Name = name;
this.Extensions = extensions;
}
throwing an ArgumentOutOfRangeException feels unnatural. Also an instance of ArgumentException is too general in my opinion.
It's easy to me to create a new exception class call it this way and have it over with. What bugs me is that it's not in the BCL/FCL and I am beginning to think there's a good reason not to have it.
Should there be one?
Morning all,
I know that this sounds like a simple referencing problem from the title this is becoming a nightmare!
I have a code class that uses the "iAnywhere.Data.AsaClient.dll". This Dll is referenced in the project and in the code class I have added this dll in the Using section.
Everything seems fine at build with no errors at all but when I go to run the application it comes up with the following Compilation Error:
Compiler Error Message: CS0246: The type or namespace name 'iAnywhere' could not be found (are you missing a using directive or an assembly reference?)
The line that the Error points to this line in the class:
using iAnywhere.Data.AsaClient;
I have set the dll to copy local and it makes no difference, the Dll is installed on my PC so is in the GAC, I use this Dll with many other C# projects and have no problems.
I have scoured Google looking for an answer and haven't found anything that points me to an answer to my problem.
Any help would be brilliant!
I am creating an web application for my tae kwon do club.
People are able to register online for a tournament.
After the registration deadline the web application generates a dendrogram. Something like this:
I am wondering now how to draw it.
Because of the fact that there are my weight and age categories i have to draw them dynamicly for each group.
What is the easiest way to draw this inside a MVC view?
Hello for I trying to use this code but for some reason it doesn't work. Really need help with this. The problem is that the label doesn't change name from "label" when I enter the site.
<asp:Label ID="Label1" runat="server" Text= label'></asp:Label>
<%
Label1.Text = "test";
if (Request.QueryString["ID"] != null)
{
string test = Request.QueryString["ID"];
Label1.Text = "Du har nu lånat filmen:" + test;
}
%>
:)
i have a DAL class file in my project, that my teacher sent me and explained to me but i did not really understand it. It has number of functions, and I understand only few of them, like with connecting to the database or creating a command object but there are 2 that I dont understand:
public static DataTable GetTable(string str)
{
OleDbConnection con = DAL.GetConnection();
OleDbCommand cmd = DAL.GetCommand(con, str);
DataTable dt = new DataTable();
OleDbDataAdapter adp = new OleDbDataAdapter();
adp.SelectCommand = cmd;
adp.Fill(dt);
return dt;
}
public static int ExecuteNonQuery(string str)
{
int num = -1;
OleDbConnection con = DAL.GetConnection();
con.Open();
if (con.State == ConnectionState.Open)
{
OleDbCommand cmd = DAL.GetCommand(con, str);
num = cmd.ExecuteNonQuery();
con.Close();
}
return num;
}
thank you :)
Hi,
I am writing a small app to automatically connect my PC to the internet at a certain time..
I am using rasdial.exe for it...
Private Sub SetIt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim windir As String = Environment.GetEnvironmentVariable("WINDIR")
Shell(windir & "\system32\rasdial.exe", AppWinStyle.NormalNoFocus)
End Sub
My question is how to make the shell function run at a specified time or after a certain interval??
Regards,
Shardul
I programmed a web site, prepared a login mechanism(via textbox, not Login tools), users want to logout, they click logout button. However, my problem is that if users don't click logout button or close web page or switch another one, How can I understand this situation?
According my mechanism, when users logout ,in DB some insertion and delete operation are making.
I also want to do this with closing page,switch another one.
Thanks.
I have a unique scenario where I want a base controller to grab some data and store it in a list. The list should be accessible from my views just as ViewData is. I will be using this list on every page and would like a cleaner solution than just shoving it in the ViewDataDictionary.
After attempting to come up with a solution, I thought I would create a custom ViewPage with a property to hold my list. My custom ViewPage would inherit from System.Web.MVC.ViewPage. However, I do not know where MVC passes the viewdata from the controller off to the view. More importantly, how do I get it to pass my list down to the view?
Thanks for the help.
Ok, the description is kind of funky, but here's my problem:
<asp:ListItem Value="0">All Leads <i>(include Archive & Trash)</i></asp:ListItem>
<asp:ListItem Value="0">All Leads <i>(include Archive & Trash)</i></asp:ListItem>
<asp:ListItem Value="0" Text="All Leads <i>(include Archive & Trash)</i>" />
<asp:ListItem Value="0" Text="All Leads <i>(include Archive & Trash)</i>" />
All three versions render the following html
All Leads <i>(include Archive & Trash)</i>
This of course fails XHTML validation. It needs to render the html like this:
All Leads <i>(include Archive & Trash)</i>
How can I fix this?
Thanks.
I've following code for file download:
FileInfo fileInfo = new FileInfo(filePath);
context.Response.Clear();
context.Response.ContentType = "application/octet-stream";
context.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(filePath));
context.Response.AddHeader("Content-Length", fileInfo.Length.ToString());
context.Response.WriteFile(filePath);
context.Response.End();
When I run it on my local IIS6 it works fine. Web browser (tested on IE8, Firefox 3.5.2, Opera 10) shows file length before I start download the file.
When I run this code on remote IIS7, web browser doesn't shows file length. File length is unknown.
Why I don't get file length when this code runs under IIS7?
I am currently playing around with the HybridSessionBuilder class found on Jeffrey Palermo's blog post:
http://jeffreypalermo.com/blog/use-this-nhibernate-wrapper-to-keep-your-repository-classes-simple/
Using this class, my repository looks like this:
public class UserRepository : IUserRepository
{
private readonly ISessionBuilder _sessionBuilder;
public UserRepository(ISessionBuilder sessionBuilder)
{
_sessionBuilder = sessionBuilder;
}
public User GetByID(string userID)
{
using (ISession session = _sessionBuilder.GetSession())
{
return session.Get<User>(userID);
}
}
}
Is this the best way to go about managing the NHibernate session / factory? I've heard things about Unit of Work and creating a session per web request and flushing it at the end. From what I can tell, my current implementation isn't doing any of this. It is basically relying on the Repository to grab the session from the session factory and use it to run the queries.
Are there any pitfalls to doing database access this way?
Hello,
I have follwing erorr after I have published site in IIS 7.5 and i don't hnow what to do
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'ProiectLicenta.MvcApplication'.
Source Error:
Line 1: <%@ Application Codebehind="Global.asax.cs" Inherits="ProiectLicenta.MvcApplication" Language="C#" %
What's the easiest way to get the URL (relative or absolute) to a Route in MVC? I saw this code here on SO but it seems a little verbose and doesn't enumerate the RouteTable.
Example:
List<string> urlList = new List<string>();
urlList.Add(GetUrl(new { controller = "Help", action = "Edit" }));
urlList.Add(GetUrl(new { controller = "Help", action = "Create" }));
urlList.Add(GetUrl(new { controller = "About", action = "Company" }));
urlList.Add(GetUrl(new { controller = "About", action = "Management" }));
With:
protected string GetUrl(object routeValues)
{
RouteValueDictionary values = new RouteValueDictionary(routeValues);
RequestContext context = new RequestContext(HttpContext, RouteData);
string url = RouteTable.Routes.GetVirtualPath(context, values).VirtualPath;
return new Uri(Request.Url, url).AbsoluteUri;
}
What's a better way to examine the RouteTable and get a URL for a given controller and action?
I need to take an uploaded image, resize it, and save it to the database. Simple enough, except I don't have access to save any temp files to the server. I'm taking the image, resizing it as a Bitmap, and need to save it to a database field as the original image type (JPG for example). How can I get the FileBytes() like this, so I can save it to the database?
Before I was using ImageUpload.FileBytes() but now that I'm resizing I'm dealing with Images and Bitmaps instead of FileUploads and can't seem find anything that will give me the bytes.
Thanks!
i have a file in my view
<form id="upload" enctype="multipart/form-data">
<input type="file" name="fileUpload" id="fileUpload" size="23" /><br />
</form>
and an ajax request
$.ajax({
url: '<%=Url.Action("JsonSave","Survey") %>',
dataType: 'json',
processData: false,
contentType: "multipart/mixed",
data:
{
Id: selectedRow.Id,
Value: 'some date was added by the user here :))'
},
cache: false,
success: function(data) {
}
});
but there is no file in the Request.Files. Whats wrong with the ajax request?
Here's an example of SetCulture attribute which inside does something like this:
public void OnActionExecuting(ActionExecutingContext
filterContext)
{
string cultureCode = SetCurrentLanguage(filterContext);
if (string.IsNullOrEmpty(cultureCode)) return;
HttpContext.Current.Response.Cookies.Add(
new HttpCookie("Culture", cultureCode)
{
HttpOnly = true,
Expires = DateTime.Now.AddYears(100)
}
);
filterContext.HttpContext.Session["Culture"] = cultureCode;
CultureInfo culture = new CultureInfo(cultureCode);
System.Threading.Thread.CurrentThread.CurrentCulture =
culture;
System.Threading.Thread.CurrentThread.CurrentUICulture =
culture;
}
I was wondering how does this affect a site with multiple users logged on and each one setting their own culture? What is the scope of a thread here with regards to the IIS worker process (w3wp) that the site is running in?
Hello, so for two-way (bi-directional) databinding in ASP, we do this...
<asp:textbox id="txtField" runat="server"
text='<%# Bind("SomeField") %>'>
</asp:textbox>
SomeField is located on the DataSource of the DetailsView that serves as the container for the textbox.
Alternatively I could do this from code-behind (using the textbox's OnDataBinding event):
protected void SomeField_OnDataBinding(object sender, EventArgs e)
{
((TextBox)sender).Text = Eval("SomeField").ToString();
}
However, EVAL is read-only...how can I specify Bind (two-way) from code-behind?
I've got this in my controller:
[HttpPost]
public void UpdateLanguagePreference(string languageTag)
{
if (string.IsNullOrEmpty(languageTag))
{
throw new ArgumentNullException("languageTag");
}
...
}
And have this jQuery code POSTing to the controller:
jQuery.ajax({
type: 'POST',
url: '/Config/UpdateLanguagePreference',
contentType: 'application/json; charset=utf-8',
data: '{ "languageTag": "' + selectedLanguage + '" }'
});
When I try to the code, however, I get the error:
Server Error in '/' Application.
Value cannot be null.
Parameter name: languageTag
What's the problem? Isn't this how to POST JSON to an MVC Controller? I can examine the POST using Fiddler and see that the request is correct. For some reason, UpdateLanguagePreference() is getting a null or empty string.
Dont ask how this works but currently it does ("^\|(.?)\|*$")....kinda. This removes all extra pipes...part one....I have searched all over no anwser yet. I am using VB2011 beta...asp web form......vb coding though!
I want to capture special character pipe (|) which is used to seperate words...i.e. car|truck|van|cycle
problem is users lead with, trail with, use multiple, and use spaces before and after...i.e. |||car||truck | van || cycle.
another example: george bush|micheal jordon|bill gates|steve jobs <-- this would be correct but when I do remove space it takes correct space out.
so I want to get rid of whitespace leading, trailing, any space before | and space after | and only allow one pipe (|)....in between alphanumeric of course.