Showing posts with label converting. Show all posts
Showing posts with label converting. Show all posts

Wednesday, March 28, 2012

Trouble converting VB Asc to C# equivalent

Hello,

Does anyone know how to convert the following line of ASP code to C#. I can't work out how to do this as there doesn't seem to be an equivalent to the Asc function.

------

...

For i = lStringLength To 1 Step -1
eText = eText & Chr(Asc((Mid(toEncrypt, i, 1))))
Next

...

------

Thanks for any help

Si.

http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=3828&lngWId=10
Eric
try the code convertor
http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx

fadil1977 wrote:

try the code convertor
http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx


Doubt that would work since C# does not have the Asc function.
Eric
you might be right ....personally i used the convertors but it does not give me 100% accuracy but i try to save the time and correct the errors manually ... and i have no clue about the convertor if it does or not work for the asc function

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.

Thursday, March 22, 2012

Trouble with Javascript when converting 2003 webproject to a 2005 project using Master Pag

Hi All,

We've got an VS.2003 ASPNET (VB) webproject which we would like to convert
to VS.2005 so that we can make use of the Master Page feature. Converting
the initial pages to 2005 is not such a problem (some minor errors) but we
run into trouble when we're trying to insert a converted page into a master
page content-placeholder.

The original page has some Javascript in it which ofcourse references to
controls in a form in the page. The form name is "frmContent", the control
is "txtSubject". In Javascript this is refered to as:
document.frmContent.txtSubject. However when this page is in the content of
a master page the frmContent form had vanished from the rendered page (view
source). Not only that: the txtSubject control is renamed to:
ctl00_phMasterContent_txtSubject. Obviously the existing Javascript will not
function anymore.

Another strange thing: suddenly there's a new <form> in the page which I
haven't created: aspnetForm. I think this is created by the master page but
I'm not sure.

Has anyone encountered the same problems that I'm facing and what's the most
simple solution? Rewriting all Javascript is going to be a lot of work..

TIA
Friso Wiskerke> Another strange thing: suddenly there's a new <form> in the page which I
> haven't created: aspnetForm. I think this is created by the master page but
> I'm not sure.

Yes, this will be the server-side form created by default in the master
page; all the content placeholders should fall within it so you can use
server controls within your Content blocks without putting a <form
runat="server"> on each individual page.

> The original page has some Javascript in it which ofcourse references to
> controls in a form in the page. The form name is "frmContent", the control
> is "txtSubject".

If the form is server-side (runat="server"), then it could create
problems, as you may usually only have one server-side form per page
(which the master has provided for you)...

> However when this page is in the content of
> a master page the frmContent form had vanished from the rendered page (view
> source).

...so, you shouldn't need to have separate <form> elements in the
content-placeholder, and removing those tags may cause the contents to
render properly.

> the txtSubject control is renamed to:
> ctl00_phMasterContent_txtSubject. Obviously the existing Javascript will not
> function anymore.

This "name mangling" is necessary to keep identifiers unique within
different parts of the page. You can work around it by substituting the
result of <% txtSubject.ClientID %> into the Javascript at the relevant
points in place of txtSubject, and the correct form name instead of
frmContent; however, this might be tedious if you have large amounts of
code that needs modifying in this way. You could possibly set up a
Javascript object called frmContent [and call the real form something
different] then add members to it with names corresponding to the
original names, pointing to the actual controls with mangled names
inserted as above.

Trouble with Javascript when converting 2003 webproject to a 2005 project using Maste

Hi All,
We've got an VS.2003 ASPNET (VB) webproject which we would like to convert
to VS.2005 so that we can make use of the Master Page feature. Converting
the initial pages to 2005 is not such a problem (some minor errors) but we
run into trouble when we're trying to insert a converted page into a master
page content-placeholder.
The original page has some Javascript in it which ofcourse references to
controls in a form in the page. The form name is "frmContent", the control
is "txtSubject". In Javascript this is refered to as:
document.frmContent.txtSubject. However when this page is in the content of
a master page the frmContent form had vanished from the rendered page (view
source). Not only that: the txtSubject control is renamed to:
ctl00_phMasterContent_txtSubject. Obviously the existing Javascript will not
function anymore.
Another strange thing: suddenly there's a new <form> in the page which I
haven't created: aspnetForm. I think this is created by the master page but
I'm not sure.
Has anyone encountered the same problems that I'm facing and what's the most
simple solution? Rewriting all Javascript is going to be a lot of work..
TIA
Friso Wiskerke> Another strange thing: suddenly there's a new <form> in the page which I
> haven't created: aspnetForm. I think this is created by the master page bu
t
> I'm not sure.
Yes, this will be the server-side form created by default in the master
page; all the content placeholders should fall within it so you can use
server controls within your Content blocks without putting a <form
runat="server"> on each individual page.

> The original page has some Javascript in it which ofcourse references to
> controls in a form in the page. The form name is "frmContent", the control
> is "txtSubject".
If the form is server-side (runat="server"), then it could create
problems, as you may usually only have one server-side form per page
(which the master has provided for you)...

> However when this page is in the content of
> a master page the frmContent form had vanished from the rendered page (vie
w
> source).
...so, you shouldn't need to have separate <form> elements in the
content-placeholder, and removing those tags may cause the contents to
render properly.

> the txtSubject control is renamed to:
> ctl00_phMasterContent_txtSubject. Obviously the existing Javascript will n
ot
> function anymore.
This "name mangling" is necessary to keep identifiers unique within
different parts of the page. You can work around it by substituting the
result of <% txtSubject.ClientID %> into the Javascript at the relevant
points in place of txtSubject, and the correct form name instead of
frmContent; however, this might be tedious if you have large amounts of
code that needs modifying in this way. You could possibly set up a
Javascript object called frmContent [and call the real form something
different] then add members to it with names corresponding to the
original names, pointing to the actual controls with mangled names
inserted as above.