Showing posts with label working. Show all posts
Showing posts with label working. Show all posts

Saturday, March 31, 2012

Set and Get

Hi everyone
i am working in .net since a while and i read a book for starting.
the problem is that i read on the internet a lot of examples using Set and Get method but really i didn't understand the meaning of it.
i did 2 web projects and i didn't use Get or Set.

in fact i didn't use this :
Public Property Text() As String
Get

End Get
Set(ByVal Value As String)

End Set
End Property

I have never define a property, i am defining a variable or a function
for example if i need a variable i put:
dim str as string
and then i give it a value.

which situation i really need to define a property
thanks.Hi,
You should use properties to add additional processing on field access. You can, for example, perform validation before assigment or check user permissions and format data on read access.

Monday, March 26, 2012

Set error level in Visual Studio 2005?

I have a website I'm working on in VS 2005. Now a lot of the pages were done in Dreamweaver, but all the HTML errors that popup in the error list are really peeing me off. These errors are irrelevant, I couldn't really care if Element 'html' is missing required attribute 'xmlns'.

How do I stop these errors from displaying? I only want serious errors, I can't seem to find how to do it in the options, and help doesnt offer any suggestions either.

ThanksLook for the page's TargetSchema property.
Is there not something I can set at the application level? I have like 300 pages in my project...
Best you can do: They are warnings, ignore them.
Thing is, the 'serious' errors will prevent the application from compiling anyways. You'll see them with the exclamation mark next to them.

Set Focus

Hi, i'm working on MS visual.net using C# asp.net web application. Can someone help with the code to set focus on a textbox when the page is load?
I tried many ways including the examples in metabuilders.com but just couldn't do it.
Wat is the code that need to be insert during pageload.

Hope someone will help me with this. Thanks.

RegisterStartupScript("myfocus", "<SCRIPT>document.all." + TextBox1.ClientID + ".focus();</SCRIPT>");

Thanks for your input. But where do i place this code in? is it in the pageload part? Because there is an error message.

Thank you.
what is the error?
pls post code and error.
the same

in vb .net
'write this function in side server code

Private Sub mySetFocus(ByVal ctrl As System.Web.UI.Control)

Dim strFocus As String
strFocus = strFocus + "<SCRIPT language='javascript'>"
strFocus = strFocus + "document.getElementById('" & ctrl.ID & "').focus();"
'if want select
strFocus = strFocus + "if ( document.getElementById('" & ctrl.ID & "').select != null ){document.getElementById('" & ctrl.ID & "').select();}"

strFocus = strFocus + "</SCRIPT>"
RegisterStartupScript("mySetFocus", strFocus)

End Sub

'call whit control for focus
call mySetFocus(txtControl)
Is there any way that we can do this without using javascript?
AFAIK, that's a client side / browser issue,
so Javascript can utimately do this in ASP.NET
hi ChinHan:

If you want set focus to a textbox when the page load,

if so txtbox is a textbox control that if you want , you can do like this

<body onload="javascript:document.all.txtbox.focus();"></body>
Thanks.. rox.scott. manage to solve the problem.. Thanks a lot.

I have another qns.. after i enter the data in the textbox, i have a search button to find the information.. but i can't press the ENTER key to search it. i need to use a mouse click.. how do i solve this.. In windows form there is no problem but in asp.net web application this problem occurs..

Thanks!
Hello,

that is another task where you can use javascript to accomplish this. In my opinion one of the best way to solve this has made Janus Kamp Hansen with his script. I want to show you this in the following example:

Public Sub DefaultButton(ByRef Page As System.Web.UI.Page, ByRef objTextControl As TextBox, ByRef objDefaultButton As Button)

' Sets default buttons.
' Created by Janus Kamp Hansen - http://www.kamp-hansen.dk
Dim sScript As New System.Text.StringBuilder()

sScript.Append("<SCRIPT language=""javascript"">" & vbCrLf)
sScript.Append("function fnTrapKD(btn){" & vbCrLf)
sScript.Append(" if (document.all){" & vbCrLf)
sScript.Append(" if (event.keyCode == 13)" & vbCrLf)
sScript.Append(" { " & vbCrLf)
sScript.Append(" event.returnValue=false;" & vbCrLf)
sScript.Append(" event.cancel = true;" & vbCrLf)
sScript.Append(" btn.click();" & vbCrLf)
sScript.Append(" } " & vbCrLf)
sScript.Append(" } " & vbCrLf)
sScript.Append("}" & vbCrLf)
sScript.Append("</SCRIPT>" & vbCrLf)

objTextControl.Attributes.Add("onkeydown", "fnTrapKD(document.all." & objDefaultButton.ClientID & ")")
Page.RegisterStartupScript("ForceDefaultToScript", sScript.ToString)

End Sub

Put this code in your code-behind module and in the page load event you can define the default buttons for the ENTER-Key like in the following sample:
 DefaultButton(Me.Page, Me.txtField, Me.cmdDefaultButton)
For any explanation please look at the web-address in the code...

HTH,
If you are using ServerSide button control, then if you have your code in buttonX_Click event then on click on that buitton only that event fires.

But, there is an alternative solution for this.

If you enter data in TextBox and press Enter, then again Page_Load event will fires as my understanding.

So what you have to do is

on Page_Load check if the textbox has value or not, if the textbox has value then call your button_click event

Ex:

on page load event

If len(textbox1.text) > 0 Then
Button1_Click(sender,e)
End if

this kind of logic might helps to your problem!
hi kbrocksi SEC.. i'm working on a C# project. Do u have it in C#? thanks!
Hi, I am having the opposite problem...I have multiple textboxes on my page, and I have set focus to the first one...but when the user presses the enter key it fires the btnEdit_Click event...causing all kinds of issues. How do I stop it from running the button click and make it set focus to the next string??

I've tried capturing the keypress event of the form, to simply move it to another control, but that doesn't seem to work either.
here's the code:


frmMain.Attributes.Add("onkeypress", "frmMain_keyPress;")

Dim sbJavaFunction As StringBuilder = Nothing
sbJavaFunction = New StringBuilder

sbJavaFunction.Append("<script language=""javascript"">function frmMain_keyPress()")
sbJavaFunction.Append("{frmmain.lblTest.Text='hi';")
sbJavaFunction.Append("if (event.keyCode == 13){")
'sbJavaFunction.Append("event.cancelBubble = true;")
'sbJavaFunction.Append("event.returnValue = false;")
sbJavaFunction.Append("document.forms[0].txtTotalPairs.Focus;")
'sbJavaFunction.Append("document.forms[0].txtTurn_TextChanged();")
sbJavaFunction.Append("}}</script>")
Page.RegisterClientScriptBlock("HandleEnterKey", sbJavaFunction.ToString())
sbJavaFunction = Nothing

any ideas would be helpful!
Chinhan...here is the translation of the above code:

private void Page_Load(object sender, System.EventArgs e)
{
DefaultButton(this.Page, this.txtField, this.cmdDefaultButton);
}

public void DefaultButton(Page Page, TextBox objTextControl, Button objDefaultButton)
{
// Sets default buttons.
// Created by Janus Kamp Hansen - http://www.kamp-hansen.dk
System.Text.StringBuilder sScript = new System.Text.StringBuilder();

sScript.Append("<SCRIPT language='javascript'>\n");
sScript.Append("function fnTrapKD(btn){\n");
sScript.Append(" if (document.all){\n");
sScript.Append(" if (event.keyCode == 13)\n");
sScript.Append(" { \n");
sScript.Append(" event.returnValue=false;\n");
sScript.Append(" event.cancel = true;\n");
sScript.Append(" btn.click();\n");
sScript.Append(" } \n");
sScript.Append(" } \n");
sScript.Append("}\n");
sScript.Append("</SCRIPT>\n");

objTextControl.Attributes.Add("onkeydown", "fnTrapKD(document.all." + objDefaultButton.ClientID + ")");
Page.RegisterStartupScript("ForceDefaultToScript", sScript.ToString());
}


Daisy, why not use theonblur event

Thursday, March 22, 2012

Set Image Control to Bitmap

Hello All, want to be able to pull images from the database and load them
into a bitmap through a stream which I have working. I then want to take
the bitmap and load it into a Image control without haveing to save the
bitmap as a file. Is this possible? Currently, I just display the bitmap
by calling Bitmap.save however, if users do not know to click the image they
can not see the full size. If I can create a bitmap from the stream I know
the size so I can set the properties of a image control and then display the
bitmap in the image. Does this make since or am I going about this the
wrong way? So in a nutshell, I am pulling images from a DB and want to
display the full size without having to actuall save the image to a file.
Any pointers?
TIAYou can make an mypage.aspx page that returns bitmap (not HTML)
1. You need to set ContentType = "img/gif"; or (jpg)
2. You need to set ContentLength to the size of the image
3. Use Response.BinaryWrite to output the image. Or since Response is a
Stream you can do Bitmap.Save(Response);
in your HTML you write <img src="http://pics.10026.com/?src=mypage.aspx">
PS: It's more efficient to use handler for that task. mypage.ashx. But aspx
will work too if you fill more comfortable with aspx.
George.
"MikeB" <m@.nospam.com> wrote in message
news:usruSre3HHA.1164@.TK2MSFTNGP02.phx.gbl...
> Hello All, want to be able to pull images from the database and load them
> into a bitmap through a stream which I have working. I then want to take
> the bitmap and load it into a Image control without haveing to save the
> bitmap as a file. Is this possible? Currently, I just display the bitmap
> by calling Bitmap.save however, if users do not know to click the image
> they can not see the full size. If I can create a bitmap from the stream
> I know the size so I can set the properties of a image control and then
> display the bitmap in the image. Does this make since or am I going about
> this the wrong way? So in a nutshell, I am pulling images from a DB and
> want to display the full size without having to actuall save the image to
> a file. Any pointers?
> TIA
>
Here is a way to do this without relying on an external handler such as
another page:
http://www.eggheadcafe.com/articles/20050911.asp
-Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
"MikeB" wrote:

> Hello All, want to be able to pull images from the database and load them
> into a bitmap through a stream which I have working. I then want to take
> the bitmap and load it into a Image control without haveing to save the
> bitmap as a file. Is this possible? Currently, I just display the bitmap
> by calling Bitmap.save however, if users do not know to click the image th
ey
> can not see the full size. If I can create a bitmap from the stream I kno
w
> the size so I can set the properties of a image control and then display t
he
> bitmap in the image. Does this make since or am I going about this the
> wrong way? So in a nutshell, I am pulling images from a DB and want to
> display the full size without having to actuall save the image to a file.
> Any pointers?
> TIA
>
>
Your page can have an Image control on it, and that Image control can point
to another page (or handler) that retrieves the image.
Here are the details:
http://SteveOrr.net/articles/ImproveYourImages.aspx
http://dotnetslackers.com/articles/...FileDenial.aspx
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"MikeB" <m@.nospam.com> wrote in message
news:usruSre3HHA.1164@.TK2MSFTNGP02.phx.gbl...
> Hello All, want to be able to pull images from the database and load them
> into a bitmap through a stream which I have working. I then want to take
> the bitmap and load it into a Image control without haveing to save the
> bitmap as a file. Is this possible? Currently, I just display the bitmap
> by calling Bitmap.save however, if users do not know to click the image
> they can not see the full size. If I can create a bitmap from the stream
> I know the size so I can set the properties of a image control and then
> display the bitmap in the image. Does this make since or am I going about
> this the wrong way? So in a nutshell, I am pulling images from a DB and
> want to display the full size without having to actuall save the image to
> a file. Any pointers?
> TIA
>
Thanks everyone for the replies.
"MikeB" <m@.nospam.com> wrote in message
news:usruSre3HHA.1164@.TK2MSFTNGP02.phx.gbl...
> Hello All, want to be able to pull images from the database and load them
> into a bitmap through a stream which I have working. I then want to take
> the bitmap and load it into a Image control without haveing to save the
> bitmap as a file. Is this possible? Currently, I just display the bitmap
> by calling Bitmap.save however, if users do not know to click the image
> they can not see the full size. If I can create a bitmap from the stream
> I know the size so I can set the properties of a image control and then
> display the bitmap in the image. Does this make since or am I going about
> this the wrong way? So in a nutshell, I am pulling images from a DB and
> want to display the full size without having to actuall save the image to
> a file. Any pointers?
> TIA
>

Set Image Control to Bitmap

Hello All, want to be able to pull images from the database and load them
into a bitmap through a stream which I have working. I then want to take
the bitmap and load it into a Image control without haveing to save the
bitmap as a file. Is this possible? Currently, I just display the bitmap
by calling Bitmap.save however, if users do not know to click the image they
can not see the full size. If I can create a bitmap from the stream I know
the size so I can set the properties of a image control and then display the
bitmap in the image. Does this make since or am I going about this the
wrong way? So in a nutshell, I am pulling images from a DB and want to
display the full size without having to actuall save the image to a file.
Any pointers?

TIAYou can make an mypage.aspx page that returns bitmap (not HTML)
1. You need to set ContentType = "img/gif"; or (jpg)
2. You need to set ContentLength to the size of the image
3. Use Response.BinaryWrite to output the image. Or since Response is a
Stream you can do Bitmap.Save(Response);

in your HTML you write <img src="http://pics.10026.com/?src=mypage.aspx">

PS: It's more efficient to use handler for that task. mypage.ashx. But aspx
will work too if you fill more comfortable with aspx.

George.

"MikeB" <m@.nospam.comwrote in message
news:usruSre3HHA.1164@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Hello All, want to be able to pull images from the database and load them
into a bitmap through a stream which I have working. I then want to take
the bitmap and load it into a Image control without haveing to save the
bitmap as a file. Is this possible? Currently, I just display the bitmap
by calling Bitmap.save however, if users do not know to click the image
they can not see the full size. If I can create a bitmap from the stream
I know the size so I can set the properties of a image control and then
display the bitmap in the image. Does this make since or am I going about
this the wrong way? So in a nutshell, I am pulling images from a DB and
want to display the full size without having to actuall save the image to
a file. Any pointers?
>
TIA
>


Here is a way to do this without relying on an external handler such as
another page:

http://www.eggheadcafe.com/articles/20050911.asp
-Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
"MikeB" wrote:

Quote:

Originally Posted by

Hello All, want to be able to pull images from the database and load them
into a bitmap through a stream which I have working. I then want to take
the bitmap and load it into a Image control without haveing to save the
bitmap as a file. Is this possible? Currently, I just display the bitmap
by calling Bitmap.save however, if users do not know to click the image they
can not see the full size. If I can create a bitmap from the stream I know
the size so I can set the properties of a image control and then display the
bitmap in the image. Does this make since or am I going about this the
wrong way? So in a nutshell, I am pulling images from a DB and want to
display the full size without having to actuall save the image to a file.
Any pointers?
>
TIA
>
>
>


Your page can have an Image control on it, and that Image control can point
to another page (or handler) that retrieves the image.
Here are the details:
http://SteveOrr.net/articles/ImproveYourImages.aspx
http://dotnetslackers.com/articles/...FileDenial.aspx
--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"MikeB" <m@.nospam.comwrote in message
news:usruSre3HHA.1164@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Hello All, want to be able to pull images from the database and load them
into a bitmap through a stream which I have working. I then want to take
the bitmap and load it into a Image control without haveing to save the
bitmap as a file. Is this possible? Currently, I just display the bitmap
by calling Bitmap.save however, if users do not know to click the image
they can not see the full size. If I can create a bitmap from the stream
I know the size so I can set the properties of a image control and then
display the bitmap in the image. Does this make since or am I going about
this the wrong way? So in a nutshell, I am pulling images from a DB and
want to display the full size without having to actuall save the image to
a file. Any pointers?
>
TIA
>


Thanks everyone for the replies.

"MikeB" <m@.nospam.comwrote in message
news:usruSre3HHA.1164@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Hello All, want to be able to pull images from the database and load them
into a bitmap through a stream which I have working. I then want to take
the bitmap and load it into a Image control without haveing to save the
bitmap as a file. Is this possible? Currently, I just display the bitmap
by calling Bitmap.save however, if users do not know to click the image
they can not see the full size. If I can create a bitmap from the stream
I know the size so I can set the properties of a image control and then
display the bitmap in the image. Does this make since or am I going about
this the wrong way? So in a nutshell, I am pulling images from a DB and
want to display the full size without having to actuall save the image to
a file. Any pointers?
>
TIA
>