Showing posts with label inside. Show all posts
Showing posts with label inside. Show all posts

Saturday, March 31, 2012

Server side code in-side aspx

I usually use code-behind pages in ASP.Net, but occasionally I have to put my
server code inside an aspx file.
I have a problem finding the correct signature for a button click event.
Private Sub loginbtn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles loginbtn.Click
compiles in in code behind, but it doesn't compile inside an aspx file.

How can I write a server event handler and put the code inside an asp file?That is the correct signature. What's the error you get?

-Brock
DevelopMentor
http://staff.develop.com/ballen

> I usually use code-behind pages in ASP.Net, but occasionally I have to
> put my
> server code inside an aspx file.
> I have a problem finding the correct signature for a button click
> event.
> Private Sub loginbtn_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles loginbtn.Click
> compiles in in code behind, but it doesn't compile inside an aspx
> file.
> How can I write a server event handler and put the code inside an asp
> file?

Server side code in-side aspx

I usually use code-behind pages in ASP.Net, but occasionally I have to put m
y
server code inside an aspx file.
I have a problem finding the correct signature for a button click event.
Private Sub loginbtn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles loginbtn.Click
compiles in in code behind, but it doesn't compile inside an aspx file.
How can I write a server event handler and put the code inside an asp file?That is the correct signature. What's the error you get?
-Brock
DevelopMentor
http://staff.develop.com/ballen

> I usually use code-behind pages in ASP.Net, but occasionally I have to
> put my
> server code inside an aspx file.
> I have a problem finding the correct signature for a button click
> event.
> Private Sub loginbtn_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles loginbtn.Click
> compiles in in code behind, but it doesn't compile inside an aspx
> file.
> How can I write a server event handler and put the code inside an asp
> file?
>

Server Side FieldSet?

I'm trying to write a Web Custom control that allows me to generate a set of server side text boxes inside the fieldset element. What I have is this:

protectedoverridevoid Render(HtmlTextWriter output)

{

StringBuilder sb =new StringBuilder();

//Begin the FieldSet if it's needed

if (this.ShowBorder )

sb.Append(string.Format("<fieldset style='WIDTH: {0}; HEIGHT: {1}'><legend>{2}</legend>",this.Width,this.Height,this.Legend));

//Add user controls

for(int i = 0; i <this.SearchFormFields.Length; i++)

{

SearchField curField =this.SearchFormFields[i];sb.Append(string.Format("<span class='fwifont'>{0}</span><br>", curField.Title));

//sb.Append(string.Format("<FWI:MultiRangeTextBox CssClass='fwifont' id=AccountNumberBox runat='server' TermName='{0}'></FWI:MultiRangeTextBox>", curField.TermName));

sb.Append("<asp:TextBox Runat='server' ID='fsdfd'></asp:TextBox>");

}

sb.Append("<br>");

//Finish off fieldset

if (this.ShowBorder )

sb.Append("</fieldset>");

sb.Append("<br>");

output.Write(sb.ToString());

}

However, the asp:text box does not render or show up. I'm guessing this has something to do with the fact that it's a server side control itself. Does anyone have any ideas on what I'm doing wrong here?

You are trying to output ASP control tags as markup. Would something like "<input type="text" id=......" rather the the ASP textbox control be more suitable?

Ta


Most unfortuantely, no, I cannot use html input fields. And actually, it not only needs to be a server side control, in reality it should be a custom web control that actually extends the asp:textbox class. I have a method that traverses all the controls on the web forms and handles the input of each textbox based on what "type" of server side text box it is.

Thursday, March 22, 2012

Server.HtmlDecode Question

I'm trying to put an image tag inside of an anchor tag that I plan to
dynamically add to a place holder tag.
The trouble is, though, that the "<" character is showing as "<" and the
">" as ">". Is there a way to get these show correctly on the html page?
Thanks in advance!
C# Code
System.Web.UI.HtmlControls.HtmlAnchor hMenuHome = new HtmlAnchor();
hMenuHome.ID = "hMenuHome";
hMenuHome.HRef = "default.aspx";
hMenuHome.InnerText = Server.HtmlDecode("<") + "img name=\"n_home\"
src=\"images/n_home.gif\" width=\"202\" height=\"50\" border=\"0\"
id=\"n_home\" alt=\"Home\" /" + Server.HtmlDecode(">");
hMenuHome.Attributes["onMouseOut"] = "MM_swapImgRestore();";
hMenuHome.Attributes["onMouseOver"] =
"MM_swapImage('n_home','','images/n_home_f2.gif',1);";
phMenuHome.Controls.Add (hMenuHome);
Resulting Html Code
<a href="http://links.10026.com/?link=default.aspx" id="hMenuHome" onMouseOut="MM_swapImgRestore();"
onMouseOver="MM_swapImage('n_home','','images/n_home_f2.gif',1);"><img
name="n_home" src="http://pics.10026.com/?src=/library/images/n_home.gif"
width="202" height="50" border="0"
id="n_home" alt="Home" /></a>"Night Air" <nospamplease@.yahoo.com> wrote in message
news:4vRfj.3024$pr6.195@.nlpi070.nbdc.sbc.com...
> I'm trying to put an image tag inside of an anchor tag that I plan to
> dynamically add to a place holder tag.
> The trouble is, though, that the "<" character is showing as "<" and
> the ">" as ">". Is there a way to get these show correctly on the html
> page?
> Thanks in advance!
>
Nevermind -- I found the problem.
I was using InnerText instead of InnerHtml.
Problem solved.
Thanks anyway!
On 6 jan, 01:19, "Night Air" <nospample...@.yahoo.com> wrote:
> "Night Air" <nospample...@.yahoo.com> wrote in message
> news:4vRfj.3024$pr6.195@.nlpi070.nbdc.sbc.com...
>
>
>
> Nevermind -- I found the problem.
> I was using InnerText instead of InnerHtml.
> Problem solved.
> Thanks anyway!
Yes, and for information Server.HtmlDecode("<") will not produce
anything good.
For html decoding you have to put HTML in it. And "<" by its own is
not HTML

Tuesday, March 13, 2012

Server.Mappath

I can't use Server.Mappath() inside a class file. Is there any way to do
this..?Use HttpContext.Current.Server.MapPath.

Hope this helps,

Mun

--
Munsifali Rashid
http://www.munsplace.com/

"Onur Bozkurt" <onur.bozkurt@.softhome.net> wrote in message
news:OIiWZ9t2DHA.1736@.TK2MSFTNGP09.phx.gbl...
> I can't use Server.Mappath() inside a class file. Is there any way to do
> this..?
It is working.
Thanks a lot...
"Onur Bozkurt" <onur.bozkurt@.softhome.net> wrote in message
news:OIiWZ9t2DHA.1736@.TK2MSFTNGP09.phx.gbl...
> I can't use Server.Mappath() inside a class file. Is there any way to do
> this..?
It is working.
Thanks a lot...
"Onur Bozkurt" <onur.bozkurt@.softhome.net> wrote in message
news:OIiWZ9t2DHA.1736@.TK2MSFTNGP09.phx.gbl...
> I can't use Server.Mappath() inside a class file. Is there any way to do
> this..?