and I have problem with Html Server Control on Visual Studio
I had create a aspx page with simple html server controls (text for input and submit bottom )
for example this is the this the code for the submit bottom:
<input type="submit" ID="Button1" runat="server" />
when I double click on the submit buttom (when i'm in design mode on visual studio )
in order to make a automatically initial code event in the aspx.cs page ( the
"protected void Convert_ServerClick(object sender, EventArgs e)" on the aspx.cs code and the onclick="Convert_ServerClick"
on the imput html bottom)
it's make me a javascript code:
u can do evrything with web server control..... which u can do with html controls.....
rather, web server controls give u more freedom, flexibility and control over behaviour of these controls...
so, for simple texxtbox or button control, i would always use <asp:textbox... > instead of <input type="text" ... >. even if i m not using accessing control/event in codebehind.
hope this helps...
Cheers!
KK
Please mark as Answer if post helps in resolving your issue
My Site
Marked as answer by danielezra on May 05, 2010 05:13 PM
danielezra
Member
152 Points
88 Posts
problem with Html Server Control
May 01, 2010 05:26 PM|LINK
I just starting to learn asp.net
and I have problem with Html Server Control on Visual Studio
I had create a aspx page with simple html server controls (text for input and submit bottom )
for example this is the this the code for the submit bottom:
<input type="submit" ID="Button1" runat="server" />
when I double click on the submit buttom (when i'm in design mode on visual studio )
in order to make a automatically initial code event in the aspx.cs page ( the "protected void Convert_ServerClick(object sender, EventArgs e)" on the aspx.cs code and the onclick="Convert_ServerClick" on the imput html bottom)
it's make me a javascript code:
<script language="javascript" type="text/javascript">
// <!CDATA[
function convert_onclick() {
}
// ]]>
instead make a code in the aspx.cs page
protected void Convert_ServerClick(object sender, EventArgs e)
{
}
when i'm using
<asp:Button ..
it's work good, but how can I do it with Html Server Control????
please mark as answer if this post answered your question
ramiramilu
All-Star
95403 Points
14096 Posts
Re: problem with Html Server Control
May 01, 2010 05:55 PM|LINK
Something like this....
<%@ Page Language="C#"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { } protected void call(object sender,EventArgs e) { Response.Write("Hello"); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <input runat="server" id="Submit1" type="submit" value="submit" onserverclick="call" /> </div> </form> </body> </html>JumpStart
danielezra
Member
152 Points
88 Posts
Re: problem with Html Server Control
May 01, 2010 08:34 PM|LINK
I know Exactly how to do it..
but I want to make automatically the
and the
onserverclick="call"
by double click on the bottom in design mode (visual studio)
it's work perfectly if I'm ussing asp bootom ( <asp:bottom > ) and when I'm double click on it it's make a aspx.cs event code
but when I'm do it with html input borrom it's make a javascript event , instead c# event..
but now i'm want work with input bottom only..
please mark as answer if this post answered your question
vijaypant
Participant
1126 Points
197 Posts
Re: problem with Html Server Control
May 01, 2010 08:48 PM|LINK
may be u forgot to add runat="server" to the control tag.
or
you didn't choose the code behind language as C# when creating the website project.
Mark as Answer on the post that helps you. This will help future readers of this post & me too :)
kedarrkulkar...
All-Star
34243 Points
5503 Posts
Re: problem with Html Server Control
May 01, 2010 09:13 PM|LINK
alright..... ramiramilu already showed u how to do this manually
to let VS create event for html server controls on its own, u can try this
http://msdn.microsoft.com/en-us/library/94113e35(VS.90).aspx
ironically, this trick used to worke in VS 2005, somehow its not there in VS 2008/10
still....u can try it
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
danielezra
Member
152 Points
88 Posts
Re: problem with Html Server Control
May 01, 2010 09:16 PM|LINK
I added the runat="server"
and I chose the code behind language c# (and when i make <asp:bottom> it's work good)
this is the aspx page
please mark as answer if this post answered your question
danielezra
Member
152 Points
88 Posts
Re: problem with Html Server Control
May 01, 2010 09:28 PM|LINK
kedarrkulkarni
they said :
Switch to Design view.
Right-click the HTML element and click Run As Server Control.
but on visual studio I dont see "run As server control"
please mark as answer if this post answered your question
kedarrkulkar...
All-Star
34243 Points
5503 Posts
Re: problem with Html Server Control
May 01, 2010 10:04 PM|LINK
i already told u....
according to follwoing post (comment from MSFT), this feature was removed from VS 2008/VS 2010
http://forums.asp.net/t/1240816.aspx#2266652
so, it seems, there's only manual way to go for newer versions...... if u r using VS2005, this should work..
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
danielezra
Member
152 Points
88 Posts
Re: problem with Html Server Control
May 01, 2010 11:16 PM|LINK
ok..
so I will use web server controls
can I use id attribute (css) on the web server like html controls??
please mark as answer if this post answered your question
kedarrkulkar...
All-Star
34243 Points
5503 Posts
Re: problem with Html Server Control
May 02, 2010 05:55 PM|LINK
of course u can....
u can do evrything with web server control..... which u can do with html controls.....
rather, web server controls give u more freedom, flexibility and control over behaviour of these controls...
so, for simple texxtbox or button control, i would always use <asp:textbox... > instead of <input type="text" ... >. even if i m not using accessing control/event in codebehind.
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site