Showing posts with label contains. Show all posts
Showing posts with label contains. Show all posts

Saturday, March 31, 2012

Trim URL

Hi,
I am involved in designing a website in which on a certain page(that contains a form) if some message is to be shown to the user the URL looks like
http://myserver/somepage.aspx?message=.....
Now if on that page the user requests re-submits the form I want the URL to be trimmed as simply http://myserver/somepage.aspx

Also is there some way that I can send such error messages through some means(like POST) such that there is no change in the url.If yes plz elaborate on it

Cheers,
-Aayush

Why don't you pass the parameter into a session, so instead of passing ?message=.....

do

Session["message"] = "...";

and in the next page you do:

string message = Session["message"].ToString();

Session.Remove("message");


you can use server variables and retrieve the required info

Wednesday, March 28, 2012

Trouble converting object to a string using format

Hi all,

I have an object (ie: type Object) which contains a date string like this: 28/04/2004 02:32:52 PM. (This object comes from a legacy COM dll that we use against our database so I can't change this type.)

I want to convert this Object's string to a date in a date format such as "yyyy-MM-dd" which is stored in another string (we get this from the globalisation settings as follows):

_dateFormat = new System.Globalization.CultureInfo(Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"], true).DateTimeFormat.ShortDatePattern.ToString();

So, taking my object with the long date string (remember, it is not a DateTime object) I want to convert it to another string using the format above... so I'd get a string containing "2004-04-28".

Anyone know how I can do this... it should be easy but I can't seem to get it to work.

TIA for any help...

MikeHello,
what don't u use something like this:

( (DateTime)urObject).ToShortDateString();

try it and tell me what happens.
Thanks Haidar... don't why I didn't get that first time around!

Cheers,

Mike
Glad i was able to help you out my friend.

Good Luck.

Monday, March 26, 2012

trouble executing SP, SqlDbType.Bit...

ASP.NET 2.0
This stored procedure fails because the variable type contains a number.
I've debugged the SP in VS2005 and it works if I change the 0/1 value of
type to true/false... How should I fix this' I cannot just replace type
with the phrase "false" or "true"... maybe using SqlDbType.Bit is wrong
This is header of this SP:
ALTER PROCEDURE dbo.DeleteMessage @dotnet.itags.org.id uniqueidentifier, @dotnet.itags.org.user int, @dotnet.itags.org.type
bit
Here is the ASP.NET code
public override void DeleteMessage(System.Guid id, int user, Boolean type)
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("SendMessage", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@dotnet.itags.org.id", SqlDbType.UniqueIdentifier).Value = id;
cmd.Parameters.Add("@dotnet.itags.org.user", SqlDbType.Int).Value = user;
cmd.Parameters.Add("@dotnet.itags.org.type", SqlDbType.Bit).Value = type;
}
}
any suggetions?
JeffIt says boolean, so you need to pass true (with no quotation marks) or false
-- for the value.
Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Jeff" wrote:

> ASP.NET 2.0
> This stored procedure fails because the variable type contains a number.
> I've debugged the SP in VS2005 and it works if I change the 0/1 value of
> type to true/false... How should I fix this' I cannot just replace type
> with the phrase "false" or "true"... maybe using SqlDbType.Bit is wrong
> This is header of this SP:
> ALTER PROCEDURE dbo.DeleteMessage @.id uniqueidentifier, @.user int, @.type
> bit
> Here is the ASP.NET code
> public override void DeleteMessage(System.Guid id, int user, Boolean type)
> {
> using (SqlConnection cn = new SqlConnection(this.ConnectionString))
> {
> SqlCommand cmd = new SqlCommand("SendMessage", cn);
> cmd.CommandType = CommandType.StoredProcedure;
> cmd.Parameters.Add("@.id", SqlDbType.UniqueIdentifier).Value = id;
> cmd.Parameters.Add("@.user", SqlDbType.Int).Value = user;
> cmd.Parameters.Add("@.type", SqlDbType.Bit).Value = type;
> }
> }
> any suggetions?
> Jeff
>
>

trouble executing SP, SqlDbType.Bit...

ASP.NET 2.0

This stored procedure fails because the variable type contains a number.
I've debugged the SP in VS2005 and it works if I change the 0/1 value of
type to true/false... How should I fix this?? I cannot just replace type
with the phrase "false" or "true"... maybe using SqlDbType.Bit is wrong

This is header of this SP:
ALTER PROCEDURE dbo.DeleteMessage @dotnet.itags.org.id uniqueidentifier, @dotnet.itags.org.user int, @dotnet.itags.org.type
bit

Here is the ASP.NET code
public override void DeleteMessage(System.Guid id, int user, Boolean type)
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("SendMessage", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@dotnet.itags.org.id", SqlDbType.UniqueIdentifier).Value = id;
cmd.Parameters.Add("@dotnet.itags.org.user", SqlDbType.Int).Value = user;
cmd.Parameters.Add("@dotnet.itags.org.type", SqlDbType.Bit).Value = type;
}
}

any suggetions?

JeffIt says boolean, so you need to pass true (with no quotation marks) or false
-- for the value.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Jeff" wrote:

Quote:

Originally Posted by

ASP.NET 2.0
>
This stored procedure fails because the variable type contains a number.
I've debugged the SP in VS2005 and it works if I change the 0/1 value of
type to true/false... How should I fix this?? I cannot just replace type
with the phrase "false" or "true"... maybe using SqlDbType.Bit is wrong
>
This is header of this SP:
ALTER PROCEDURE dbo.DeleteMessage @.id uniqueidentifier, @.user int, @.type
bit
>
Here is the ASP.NET code
public override void DeleteMessage(System.Guid id, int user, Boolean type)
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("SendMessage", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@.id", SqlDbType.UniqueIdentifier).Value = id;
cmd.Parameters.Add("@.user", SqlDbType.Int).Value = user;
cmd.Parameters.Add("@.type", SqlDbType.Bit).Value = type;
}
}
>
any suggetions?
>
Jeff
>
>
>

Thursday, March 22, 2012

Trouble with QueryString

Hi,

I access a particular page by specifying the page's name and extension like so:

http://localhost:xxxx/MyFiles/Lucky/
The Lucky directory contains a webpage named Default.aspx. I can access is without needing to type in the page's name and
extension. This page uses a querystring and is only specified when needed (e.g. keywords=sam). My trouble is that if I
access the page without specifying the page's name and extension, somehow the querystring is given a value on its own.
Debugging reveals that the querystring contains the value of "default.aspx"

What could be causing this issue? I've been at this for a few hours now with no luck. Any help would be greatly appreciated.

Thanks,
RoshawnRoshawn,
Are you doing any URL rewriting or redirection? I've seen this
before when doing redirection and not filtering out the default page as a
possible value.

--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"Roshawn" <radawson218@.yahoo.comwrote in message
news:%2374iTQNRHHA.2124@.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

Hi,
>
I access a particular page by specifying the page's name and extension
like so:
>
http://localhost:xxxx/MyFiles/Lucky/
>
The Lucky directory contains a webpage named Default.aspx. I can access
is without needing to type in the page's name and extension. This page
uses a querystring and is only specified when needed (e.g. keywords=sam).
My trouble is that if I access the page without specifying the page's name
and extension, somehow the querystring is given a value on its own.
Debugging reveals that the querystring contains the value of
"default.aspx"
>
What could be causing this issue? I've been at this for a few hours now
with no luck. Any help would be greatly appreciated.
>
Thanks,
Roshawn


Hmm, you're absolutely right!

I am doing URL rewriting, using Regex of course. I discovered that one of my Regex rules was incorrect. That's what was
causing the trouble as I wasn't filtering out the default page.

Thanks for the help, :-)
Roshawn

Mark Fitzpatrick wrote:

Quote:

Originally Posted by

Roshawn,
Are you doing any URL rewriting or redirection? I've seen this
before when doing redirection and not filtering out the default page as a
possible value.
>