|
|
//TODO: INSTANT C# TODO TASK: Insert the following converted event handlers at the end of the 'InitializeComponent' method for forms, 'Page_Init' for web pages, or into a constructor for other classes:
Button2.Click += new System.EventHandler(Button2_Click);
private void Button2_Click(object sender, System.EventArgs e)
{
CreateVirtualDir("savan", "sampletest", "D:\\Savan\\Backup\\ChoicesWildNet\\Application Sohel");
}
private void CreateVirtualDir(string WebSite, string AppName, string Path)
{
System.DirectoryServices.DirectoryEntry IISSchema = new System.DirectoryServices.DirectoryEntry("IIS://" + WebSite + "/Schema/AppIsolated");
//Dim CanCreate As Boolean = Not IISSchema.Properties("Syntax").Value.ToString.ToUpper() = "BOOLEAN"
IISSchema.Dispose();
// If CanCreate Then
bool PathCreated = false;
try
{
System.DirectoryServices.DirectoryEntry IISAdmin = new System.DirectoryServices.DirectoryEntry("IIS://" + WebSite + "/W3SVC/1/Root");
//make sure folder exists
if (! (System.IO.Directory.Exists(Path)))
{
System.IO.Directory.CreateDirectory(Path);
PathCreated = true;
}
//If the virtual directory already exists then delete it
foreach (System.DirectoryServices.DirectoryEntry VD in IISAdmin.Children)
{
if (VD.Name == AppName)
{
IISAdmin.Invoke("Delete", new string[] {VD.SchemaClassName, AppName});
IISAdmin.CommitChanges();
break;
}
}
//Create and setup new virtual directory
System.DirectoryServices.DirectoryEntry VDir = IISAdmin.Children.Add(AppName, "IIsWebVirtualDir");
VDir.Properties["Path"][0] = Path;
VDir.Properties["AppFriendlyName"][0] = AppName;
VDir.Properties["EnableDirBrowsing"][0] = false;
VDir.Properties["AccessRead"][0] = true;
VDir.Properties["AccessExecute"][0] = true;
VDir.Properties["AccessWrite"][0] = false;
VDir.Properties["AccessScript"][0] = true;
VDir.Properties["AuthNTLM"][0] = true;
VDir.Properties["EnableDefaultDoc"][0] = true;
VDir.Properties["DefaultDoc"][0] = "default.htm,default.aspx,default.asp";
VDir.Properties["AspEnableParentPaths"][0] = true;
VDir.CommitChanges();
//the following are acceptable params
//INPROC = 0
//OUTPROC = 1
//POOLED = 2
VDir.Invoke("AppCreate", 1);
}
catch (Exception Ex)
{
if (PathCreated)
{
System.IO.Directory.Delete(Path);
}
Response.Write(Ex.Message.ToString());
}
// End If
}
David Anton
http://www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
C++ to VB Converter: converts C++ to VB
C++ to Java Converter: converts C++ to Java
Instant C++: converts C# to C++/CLI and VB to C++/CLI
|
|
|
|
|
|
I am using Response.write to use google maps javascript to put markers on a map, reading latitude and longitude from a SQL Server database. I read the values from the database creating values Lat and Lng and use these in the javascript. However the values of Lat and Lng are not recognised in the javascript. If I hard-code values eg GLatLng(50.953,-4.123) and 1 for userID, a marker is set OK. Can anyone help? I've tried using ClientScript.RegisterClientScriptBlock but got nothing.
<% Dim conn As SqlConnection
conn = New SqlConnection("Data Source=beish2;Initial Catalog=HA4;Integrated Security=True")
conn.Open()
Dim sqlComm As New SqlCommand("SELECT PlaceID,PlaceName, PlaceLat, PlaceLng FROM Places ORDER BY PlaceName", conn)
Dim r As SqlDataReader = sqlComm.ExecuteReader()
While r.Read()
Dim username As String = CStr(r("PlaceName"))
Dim userID As Integer = CInt(r("PlaceID"))
Dim Lat As Double = CDbl(r("PlaceLat"))
Dim Lng As Double = CDbl(r("PlaceLng"))
Response.Write("" & vbCrLf)
Response.Write("//<![CDATA[" & vbCrLf)
Response.Write("map.addControl(new GScaleControl());" & vbCrLf)
Response.Write("var point = new GLatLng(Lat,Lng);" & vbCrLf)
Response.Write("var marker = createMarker(point, userID);" & vbCrLf)
Response.Write("map.addOverlay(marker);" & vbCrLf)
Response.Write("//]]>" & vbCrLf)
Response.Write("" & vbCrLf)
Response.Write(userID)
End While
r.Close()%>
|
|
|
|
|
You can't use VB variables in the Javascript code. They don't exist in the same place, and they don't exist at the same time. Add code to create the variables in the Javascript code. Example:
Response.Write("var Lat = " & Lat.ToString(CultureInfo.InvariantCulture) & ";")
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks for reply. Not sure how I get the values from the database (MS SQL Server). Do I need to have the database connection, SQL code and reading of records all within the javascript. If so, do you have any sample code for doing this type of action, or a web site where there are decemt tutorials. I'm not too familiar with javascript
Ken
|
|
|
|
|
beish1 wrote: Thanks for reply. Not sure how I get the values from the database (MS SQL Server).
But you already have code that reads the values from the database. What's wrong with that code?
beish1 wrote: Do I need to have the database connection, SQL code and reading of records all within the javascript.
No, you should absolutely not call the database from the Javascript. It's possible to do so, but that means that anyone can read the database login in the page source.
I showed you how to create a Javascript variable that contains the value from your VB variable. Is there something in that example that you don't understand?
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks for your info - and patience! I wasn't sure what CultureInfo.InvariantCulture
was - do I use that expression everytime for each variable?
Ken
|
|
|
|
|
beish1 wrote: I wasn't sure what CultureInfo.InvariantCulture
was
That's a neutral culture. Among other things it specifies the decimal separator to be a period, which is useful when you format a floating point number to be used in Javascript code.
beish1 wrote: do I use that expression everytime for each variable?
You only need to specify a culture or format when you convert a value where the format depends on the culture. An integer value, for example, is formatted the same regardless of the culture.
---
single minded; short sighted; long gone;
|
|
|
|
|
Could not copy temporary files to the output directory.
hello can any one solve this i made copy local true but it dident work
|
|
|
|
|
Hey all. Im trying to consume RSS feeds in my app but it doesnt seem to work.
No matter which feed i use i get the same error message. The error message is:
"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond"
Does anyone know if there is a setting i must change, or some kind of codeline to add to the config file?
Dazz
|
|
|
|
|
Hrrmmm.... Ik looks like a firewall blocking outbound traffic may cause this problem..?
|
|
|
|
|
hi friends
i am using telerik component in my aspx page. it work properly in internet explorer-6 but it not work in Mozillafirefox. how i manage all the control in firefox explorer aand how to manage all control of asp.net for Mozilla firefox
please help me
Piyush Vardhan Singh
Programmer
TAS NewDelhi
India
|
|
|
|
|
Well, either the control is FF compatible, or it isn't. ASP.NET actually detects the capabilities of the browser, and modifies it's controls to suit. My experience with Telerik is that their controls work fine in FF. I'd recommend going to their support page and asking them about the specific problem you have with a specific control.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello Everyone,
I want to embed any music player like Real Player and Window Media Player to run the Audio/Video in this media player ...........
Suggest me the way for this problem...............
|
|
|
|
|
|
I have two questions to ask in this forum
1) How to include java script file in .aspx file?
2) I wrote a following class with a function called JavaScriptFunction. The issue I am facing is when I am using this function to display message, the background of web page was white ie no style sheets were applied to .aspx page and no others controls were displayed. When I click on “ok”, I am coming back to same page.
The code for the JavaScriptFunction is as follows
public static void JavaScriptFunction(string alertmessage)
{
System.Web.HttpContext.Current.Response.Write("");
System.Web.HttpContext.Current.Response.Write("alert('" + alertmessage + "')");
System.Web.HttpContext.Current.Response.Write("");
}
.
Thanks in advance
surya
|
|
|
|
|
1) How to include.....
<script src="path.js" type="text/javascript"></script>
2) I wrote a following
Instead of response.Write ,try this
Page.RegisterStartupScript("p", "<script>alert('" + alertmessage + "');</script>");
Best Regard
Pathan
---------------------------------------------------
|
|
|
|
|
The way I understand about your problem is that you want to show a page with or without stylesheet dynamically by clicking a button.
In ASP.NET 1.1, you should handle this functionality in base page. There should be one property that allow users to change the path of CSS. In my project, we allows users to change the themes dynamically. Since there is no build-in theme system in ASP.NET 1.1, we handled it in base page.
In ASP.NET 2.0, you can have more than one theme. So, you can change one plain theme to another theme dynamically by changing themeId or Skin ID.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
suryany72 wrote: How to include java script file in .aspx file
Frnd,
between
<title>
<script language="javascript">
//Code of script
</script>
suryany72 wrote: a function called JavaScriptFunction
<title>
<script language="javascript">
function CallMe()
{
alert("Hello World");
return false;
}
</script>
call this function on click of any button
If the message is useful for U then please Rate This message...
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
Hi..
Could any one tell me how to add a variable value(or property value) from codebehind to a function in a javascript file?
I am too late but i will never give up
|
|
|
|
|
Something like that?
button.Attribute.Add("onclick","func('val');");
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Sorry I didn't mean as a parameter for a function.I mean something like the following:
<br />
function donow()<br />
{<br />
var b=ss;
}<br />
And the script file isn't running by clicking a button.it is an ordinal script block in a javascript file.
I am too late but i will never give up
|
|
|
|
|
TheEagle wrote: function donow()
{
var b=ss;//where ss value is set from code behind
}
I don't think it can be done directly.
But you can use server-side hidden field to commute between client-side and server-side.
<input id="Hidden1" type="hidden" runat="server"/>
In Form_load
<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
Hidden1.Value = "13";<br />
}
You can set like that..
In Client-side ~
<script language="javascript" type="text/javascript"><br />
function getvalue(){<br />
var var1 = document.getElementById('Hidden1').value;<br />
}<br />
</script><br />
So, Even thought you can't set like that "var b=ss; " directly. but you can set "hidden.value = ss;" and then, var b = hidden.value ;
Hope it helps.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
I did as you told me and it works.
But I think if it is possible to set the variable in code behind using
ClientScript.RegisterClientScriptBlock it will be more secure.Because I brought the value of the variable from database.So in the codebehind it will be something as the following:
<br />
ClientScript.RegisterClientScriptBlock(this.GetType(),"MyScript",<br />
"<script language='javascript' src='functions.js'>function getvalue(){var var1 ="+ss+<br />
";}</script>");<br />
But it didn't work with me...Any way if I couldn't find any more secure solution I will continue using your solution which will solve my problem too.
Thank you very much for helping me all the time.
I am too late but i will never give up
|
|
|
|