|
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)
|
|
|
|
|
I have the page break problem in my report. In the report first I placed a table with contains 50 rows(data will be shown in two pages) and after the table I placed the matrix object becuase the number of cols is not fixex. The problem is that if the number of columns in the matrix is greater than 10 then it prints the remaining columns in the next page but at the same I am getting the page breaks in the first table i.e between 1St and 2nd page I am getting page break.
How can I delete the page breaks.
Kalyan
|
|
|
|
|
Hi,
I am trying to cache a custom control so that I do not have to call LoadControl ("MyControl.ascx" ) every time my OnInit function is called. So, I do this:
object cachedctrl = Session["cachedcontrol"];
if ( cachedctrl != null ) <br />
{ <br />
Controls.Add ( (Control)cachedctrl ); <br />
return; <br />
} <br />
Control ctrl = LoadControl ( "MyControl.ascx" ); <br />
Controls.Add ( ctrl ); <br />
<br />
Session["cachedcontrol"] = ctrl;
It kinda works, except that the viewstate for the page is lost when I load it from the cache!
can anybody explain why this is happening and suggest a workaround?
thank you.
|
|
|
|
|
I cant explain what is happening but I will ask this. Why are you calling LoadControl everytime the OnInit function is called? And when you say Custom Control do you really mean User Control?
Example of LoadControl Use[^]
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)
|
|
|
|
|
Yes, sorry, when I say Custom Control I mean User Control.
I call LoadControl at every OnInit because I thought this was the way I was suppose to add dynamic controls to a page.
is it not the right way?
|
|
|
|