Solved

VB.NET to C#

Posted on 2006-06-22
8
227 Views
Last Modified: 2012-05-05
Hello Experts,

I am new to C# could anyone pls tell me how to convert the following function from VB to C#

 Private Function Msgbox(ByVal strMessage As String)

        Dim strScript As String = "<script language=JavaScript>"
        strScript += "alert(""" & strMessage & """);"
        strScript += "</script>"

        If (Not Page.IsStartupScriptRegistered("clientScript")) Then
            Page.RegisterStartupScript("clientScript", strScript)
        End If

    End Function

Also:

            Dim dt As DateTime
            Dim dt1 As DateTime
            dt = New DateTime(sy, sm, sd, sh, smm, 0)
            dt1 = New DateTime(ey, em, ed, eh, emm, 0)

Any help appreciated.
0
Comment
Question by:radhakrishan
  • 4
  • 2
  • 2
8 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 250 total points
ID: 16960886
private void MsgBox(string strMessage)
{
    string strScript = "<script language=javascript>";
    strScript += "alert(\"" + strMessage + "\");";
    strScript += "</script>";

    if (!Page.IsStartupScriptRegistered("clientScript"))
        Page.RegisterStartupScript("clientScript", strScript);
}
0
 
LVL 18

Expert Comment

by:Ravi Singh
ID: 16960898
private void MsgBox(string strMessage)
{
     string strScript = "<script language=JavaScript>";
     strScript += "alert(\"" + strMessage + "\");";
     strScript += "</script>";

     if (!Page.IsStartupScriptRegistered("clientScript"))
     {
          Page.RegisterStartupScript("clientScript", strScript)
     }
}


DateTime dt = new DateTime(sy, sm, sd, sh, smm, 0);
DateTime dt1 = new DateTime(ey, em, ed, eh, emm, 0);
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16960903
Second part:

    DateTime dt = new DateTime(sy, sm, sd, sh, smm, 0);
    DateTime dt1 = new DateTime(ey, em, ed, eh, emm, 0);
0
 
LVL 18

Expert Comment

by:Ravi Singh
ID: 16960954
sorry carl, posted on same minute!
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:radhakrishan
ID: 16961079
Hi Guys,

Thanks for the reply.

In the 2nd Part:

DateTime dt = new DateTime(sy, sm, sd, sh, smm, 0);
DateTime dt1 = new DateTime(ey, em, ed, eh, emm, 0);

I get an error on each argument cannot convert string to int.

Should I be writing somthing like int.Parse(sy)
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16961100
If your variables are strings containing ints then yes.
0
 

Author Comment

by:radhakrishan
ID: 16961109
Yeah,
Thanks for the reply.
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16961157
Thanks for the points, although I think a Split may have been more appropriate since Zephyr and myself posted the same answer at the same time.

Post a request in Community Support if you want to change the point split.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now