|
Thanks man. That's exactly what I did .
Here we go, just in case you'll need it.
Import System.Management library into your project first then,
Try<br />
' Create a ManagementClass object<br />
Dim managementClass As System.Management.ManagementClass = New System.Management.ManagementClass("Win32_Share")<br />
' Create ManagementBaseObjects for in and out parameters<br />
Dim inParams As System.Management.ManagementBaseObject = managementClass.GetMethodParameters("Create")<br />
Dim outParams As System.Management.ManagementBaseObject<br />
' Set the input parameters<br />
inParams("Description") = "My Shared Files"<br />
inParams("Name") = partner_name<br />
inParams("Path") = Session("Path").ToString() ' This is a path to existing directory<br />
inParams("Type") = 0<br />
' Disk Drive<br />
' Invoke the method on the ManagementClass object<br />
outParams = managementClass.InvokeMethod("Create", inParams, Nothing)<br />
' Check to see if the method invocation was successful<br />
If (CType(outParams.Properties("ReturnValue").Value, Integer) <> 0) Then<br />
Throw New Exception("Unable to share directory.")<br />
End If<br />
Catch ex As Exception<br />
'Return e.Message<br />
End Try
|
|
|
|
|
I have developed a web application .NET 2.0. with dropdownlists in itemtemplates on a fovmview. Is it possible to get the dropdownlist to expand when the mouse is positioned over it?
|
|
|
|
|
When I try to assign a TextBox.Text property that contains a tag for example: into a string variable I get the following error.
<br />
A potentially dangerous Request.Form value was detected from the client (TxtName="<BR>"). <br />
TxtName is the TextBox control.
Please help.
|
|
|
|
|
That is a .NET protection to avoid cross scripting attacks. A clue Googled[^]. Just be careful with this because if you turn this off you must always always check the text for these types of characters, which you should be doing anyway.
I dont know of a good Regular Expression for this and if someone does I would love to see it too.
You might also try doing strVariable = Textbox.Text.UrlEncode
-- modified at 14:28 Tuesday 27th February, 2007
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
CleaKO wrote: strVariable = Textbox.Text.UrlEncode
Thankyou Cle
I ve tried strVariable = Textbox.Text.UrlEncode but it Textbox.Text doesn't have UrlEncode property. What do I need to import here?
|
|
|
|
|
Hi,
Can you send me the string that you are storing in a variable??
Just wanted to know whether you are storing 'm,./?>
|
|
|
|
|
Harini311 wrote: Just wanted to know whether you are storing 'm,./?>
I am not sure what 'm,./?> does.
What I am trying to do is only this suppose I have entered some text between '<' and '>' in a TextBox control and in the code behind I assign as
str=TextBox1.Text in page load event
This causes the error
|
|
|
|
|
Hi
What I meant is that suppose you enter some characters '<' and '>' then this will definitely give you an error..... that is why I said whether you have entered text like "<>/" something like that.....I think it is better to validate and should accept only valid characters.
Rate this message. Thank you. Harini
|
|
|
|
|
I am developing in ASP.NET 2.0. I have a pdf file that I get from a blob field in our DB. When I try to display the file in the Page_Load I get a blank page. Looking at the properties for the page I see that the url is about:blank and all the other properties show as not available. When I put a button on the page and have the code to show the the pdf file in the button click event the pdf displays correctly after the page loads and I press the button.
This code doesn't work:
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
Response.ContentType = "Application/pdf";
byte [] myBytes = somePDFFileInBinaryFormat;
Response.Buffer = true;
Response.BinaryWrite(myBytes);
Response.Flush();
Response.Close();
}
but this does when i press the button to cause a postback:
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Clear();
Response.ContentType = "Application/pdf";
byte [] myBytes = somePDFFileInBinaryFormat;
Response.Buffer = true;
Response.BinaryWrite(myBytes);
Response.Flush();
Response.Close();
}
Any idea what the problem is?
J
|
|
|
|
|
Maybe you should do this in the Render event instead of the Page_Load event?
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
I've tried that. I've also tried the OnLoadComplete and Prerender methods. Same result.
|
|
|
|
|
Have you tried instead of showing the PDF on the page to just redirect to that file, that should work as well.
Response.Redirect("Test.pdf")
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
urgent
i added server button2 (webcontrol)..
I went when i click to button2 to javescript fuction to run
i try to add button22.attribute.add("vd()","")
and Iwant to make vaildation fuction using javascript if the page is not vaild canel postback
function vd()
{
page_activevalidation=false()
}
how can do it excatly
thanks
|
|
|
|
|
Im going to answer this even though it looks fishy.
Tkml236 wrote: i try to add button22.attribute.add("vd()","")
This should be Button22.Attributes.Add("onClick", "vd();")
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
but how can I can
* cheack if webform is valid
and if not * cancel postback
using javeScript
thanks
|
|
|
|
|
You will need to lookup JavaScript validations in order to do that. If you are trying to use .NET validators then that is a whole different story because in the code behind you would check for If Page.IsValid . For the JavaScript you would check the entire page in one long validation function in order to determine if it is valid or you will have to set a hidden field to false etc... as you go through the validation criteria.
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
You need a return:
So it should be:
This should be Button22.Attributes.Add("onClick", "return vd();")
So if your function vd() returns false the page does not post back.
Ben
|
|
|
|
|
how can I use this please
can i get value from javascript
i think when i click on button first check the attributesfuction vd()
and if for example return false how can I get false value to cancel postbak
|
|
|
|
|
So if your javascript looks like:
function vd()
{
page_activevalidation=false()
}
you need to change it to something like:
function vd()
{
if (document.getElementById("textboxid").value == "")
{
window.alert("You need to enter data in textbox");
return false;
}
else
{
return true;
}
}
Another option would be instead of writing the javascript your self you can use the validator controls that Visual Studio provides.
Ben
|
|
|
|
|
1. Adding javascript function to button
btn.Attribute.Add("onclick","return Foo();")
2. No Post
function Foo(){
if(isNotValid)return false;
}
3. Accessing client-side variable from Server-side.
Add one Server-side Hidden Field.Then, Set the value to this hidden field from Javascript. And it's available to be accessed from Server-side code also..
More Info:
Read AskForComment() function and "Accessing the Client-side variable (variable named “str” in this sample ) from Server-side Code" from the following article.
http://michaelsync.net/2007/01/01/custom-javascript-dialog/
Hope, it would help.
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.
|
|
|
|
|
We want to do some cleanup with the user clicks the close button (the 'X' button int he top-tight corner of the window). How do I detect that and in turn, execute some C# code?
I tried doing some stuff with onUnload in javascript, but that didn't work out.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
This has been posted quite a few times and the answers are always that you cant accurately depend on any method to detect this. I would suggest not depending on the user doing something on their end to clean up anything since the web is stateless you really dont have a good way of knowing or requiring them to do anything to recieve that information.
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
Getting the javascript onUnload handler to work from a master page is easy. Getting the javascript to call a C# function on a asp.net page is what I'm asking about.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
This is kind of a lame solution, but if you have some sort of Close button on the browser itself, it would be easy enough to have the javascript call the click event on that button. I am just curious what sort of clean up are you thinking about doing?
Ben
|
|
|
|
|
What will you do if they have Scripting disabled?
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|