|
Hi
I would like to know how would i display a messageBox in a web form. I know in Windows forms you would use something like
MessageBox.Show("Hello");
How could i show this kind of dialog box (or equivalent)on a web form, if a user clicks a button??
Cheers
|
|
|
|
|
if you want to use message box in your web page use Jvascript for that !!!
<code>
<script langauge="javascript" runat="Server">
void MessagBox(string s)
{
alert(s);
}
</script>
</code>
and on button Click call that function!!!
|
|
|
|
|
Thanks for that
now i'd just like to know, if i had a hyperlink on my page and when the user clicked on that link a messageBox should appear.
How could i acheive this?? similar procedure using client side scripts??
Cheers
|
|
|
|
|
Yes, You can use on link button and call that method onclick of that link !!!
|
|
|
|
|
Hey ya'll,
Over the years ;
a) I've forgotten my geometry
b) Never really had a good handle on it
c) In class was flirtin with the girl in front of me
d) all of the above
Anyway having said that, my problem;
I'm working on a graphics application and am adding a line tool.
I want to define an area around the tool which I can use for hit testing.
My thoughts were to define a rectangle 5 pixels either side of the line and the length of the line but I just cannot get a handle on it??
The line can be at any angle and be of any length.
------------------------ Upper boundry (??)
------------------------ The line
------------------------ Lower boundry (??)
Thanks ya'll,
Mike
Life is not measured by the number of breaths we take, but by the
moments that take our breath away. "George Carlin"
|
|
|
|
|
You mean 5px above, and 5px below? Or 2.5px above and below?
Either way, you need to calculate the angle of the line, which basically is:
int lenX = startX-endX;
int lenY = startY-endY;
float length = sqrt(lenX^2 + lenY^2);
float angle = inverse cos(length/lenX)
Check up on google, there's lots of maths there.
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
Thanks for the help, will give it a try. Something so simple, guess I was over engineering it!
Mike
Life is not measured by the number of breaths we take, but by the
moments that take our breath away. "George Carlin"
|
|
|
|
|
Hi Mike,
what you need is algebra, not geometry.
a straight line can be represented by a*x + b*y + c = 0
having two points (x1,y1) and (x2,y2) you can find a,b,c (except for an
arbitrary scale factor).
The orthogonal distance of an arbitrary point (x,y) to that same line is given
by a*x + b*y + c which is obviously zero for all points on the line.
So for hit testing I would:
- calculate a,b,c once
- checking a*x + b*y + c is sufficiently small
- for a finite line segment: also checking x is in an acceptable range
smallest of x1 and x2 minus some, largest of them plus some; same for y.
BTW: officially you should normalize the scale factor such that e.g.
a*a+b*b+c*c=1; in reality you can skip that and replace the distance check by:
(a*x + b*y + c)^2 small with respect to a*a+b*b+c*c
FYI: there is a completely different way to do all this:
create a memory-based bitmap where you draw the same line with a much thicker pen,
of a selected color; now just sample the color at (x,y) to see whether it is
part of the thick line. This also works for more complex shapes and drawings
provided you use different colors for different pickables (a problem will arise
where they overlap though).
|
|
|
|
|
Luc,
Thanks thats exactly what I needed. Had the slope, deltaX and deltaY and from that calculated the angle but got stuck there. I guess what I thought would be easiest would be to find the 4 points perpendicular to the line and just do a rectangle.contains(point).
Thanks,
Mike
Life is not measured by the number of breaths we take, but by the
moments that take our breath away. "George Carlin"
|
|
|
|
|
No, the sides of a rectangle are always parallel to the axis - but you can do something similiar with Path/Region - structures.
Let's say you've got the endpoints (x,y) and (x',y') of your line, then the vector perpendicular to this will be
(- y'+ y,x' - x). Normalize this with the reziprocal of the length: l = sqrt((x'-x)^2 + (y'-y)^2) and you get an
vektor (vx,vy) (vx = -(y'+y)/l, vy = (x'-x)/l),
now you add (d = desired width) d/2*n and -d/2*n to the endpoints to get 4 new points that define the outline of your shape (use a path with this 4 points to create a region).
Now you only have to add two circles with radius d/2 and centers of your original endpoints of the line to the region and you have a region describing the desired neighbourhood - and you can do Hittesting in it
|
|
|
|
|
CKnig,
Thanks, appreciate the help!
Mike
Life is not measured by the number of breaths we take, but by the
moments that take our breath away. "George Carlin"
|
|
|
|
|
Hi,
I have this formula -
Double i_decel_rate = ((Convert.ToInt32(textbox1.Text) * 10000) / Convert.ToInt32(textbox2.Text));
But for some reason the double doesn't display as double - like a value 7.98 is shown as 7 - it is not showing the decimals - but does display the integer value. I am using a text box to display this value - is there a way in webforms to print a value? Like the windows forms has messagebox.show()?
is anything off with the syntax?
thanks.
modified on Monday, December 10, 2007 8:41:47 AM
|
|
|
|
|
VK-Cadec wrote: is anything off with the syntax?
Yes, if you do division using integers the result is an integer (as you've found).
Double i_decel_rate = ((Convert.ToDouble(textbox1.Text) * 10000.0) / Convert.ToDouble(textbox2.Text));
|
|
|
|
|
Hi, iam doing windows application in c#
i have one textbox and datagridview control....
when i enter "productid" in textbox ,it can fetch the data from database
and displayed in datagridview..
when i enter another 'productid" in textbox ,it can also fetch and displayed in datagridview in second row....
i,e in datagrid both previous data results and recent data results are also
to be displayed ---
please give me solution...
murali krishna
|
|
|
|
|
Huh? Can you be a little more clear (not what you are trying to achieve, but how you are trying to achieve it)?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
hi
I have done a project in which i am connecting a application to a server the purpose is text transaction ....i have done it using threads ..............i want know is there any way to check how much resource is getting utilized
regards
sindhu tiwari
its me sid
|
|
|
|
|
Hi friends,
Thanks to those who answered my first question. Now I have other.
Do you think it is worth it to buy books for C# 2005 and .Net 2.0 when VS 2008 and .Net 3.0 are around the corner?
I'm afraid of buying those books, eat them and then, Microsoft changes the examinations to the latest technology.
What do you think?
I'm thinking in buying this pack:
http://www.amazon.com/gp/product/0470048409/ref=olp_product_details?ie=UTF8&me=&seller=[^]
|
|
|
|
|
Hi
the code below incrments by 1 each time and adds1 to the end number, is there a way for it to increment 01,02,03 rather then 1,2,3
string[] split = db.Split('_');
string s_number = split[1];
int i_number = Int32.Parse(s_number);
i_number++;
s_number = i_number.ToString();
db = split[0] + "_" + s_number;
cheers
|
|
|
|
|
You can use String.Format()[^]. You can find the right format string in the examples.
Standards are great! Everybody should have one!
|
|
|
|
|
1 is a number which you can increment.
01 is a string representation of a number. You cannot increment a string as it has no real meaning to do so.
You should increment you number (1) and then apply string formatting to that number (myNumber.ToString("00")) to get the required format.
|
|
|
|
|
Guess you missed my other reply
Yeah, either .Format("00");
or like i said last time .PadLeft(2, '0');
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
ok so should it be added somewhere in the line below as this is the entire format of what is being outputted?
db = split[0] + "_" + s_number;
|
|
|
|
|
Instead of getting someone here to hold your hand all the way through... try some stuff out yourself next time given the hints that have been provided.
db = split[0] + "_" + s_number.ToString("00");
|
|
|
|
|
well done thats great thats what ive already tried which is why i posted the question
db = split[0] + "_" + s_number.ToString("00"); this does not work error message is there are invalid areguments in the code
|
|
|
|
|
it should be this:
s_number = i_number.ToString("00");
not
db = split[0] + "_" + s_number.ToString("00");
|
|
|
|