Click here to Skip to main content
15,888,286 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionASP.Net VB: Dynamic refresh of webpage after completion of asynchronous task Pin
ajaysh7317-Feb-16 14:20
ajaysh7317-Feb-16 14:20 
Questioncascading with javascript Pin
Luis Oliveira 196617-Feb-16 5:40
Luis Oliveira 196617-Feb-16 5:40 
QuestionGridView behaving Strangely in an asp.net web page. Pin
Member 1221350616-Feb-16 7:08
Member 1221350616-Feb-16 7:08 
AnswerRe: GridView behaving Strangely in an asp.net web page. Pin
Richard Deeming16-Feb-16 7:27
mveRichard Deeming16-Feb-16 7:27 
GeneralRe: GridView behaving Strangely in an asp.net web page. Pin
Member 1221350616-Feb-16 7:33
Member 1221350616-Feb-16 7:33 
QuestionHow to create a language translator in asp.net using c#? Pin
Raja Ganapathy16-Feb-16 2:15
Raja Ganapathy16-Feb-16 2:15 
AnswerRe: How to create a language translator in asp.net using c#? Pin
Richard MacCutchan16-Feb-16 3:15
mveRichard MacCutchan16-Feb-16 3:15 
Questionhave a problem in custom control with javascript Pin
Member 1207470715-Feb-16 18:57
Member 1207470715-Feb-16 18:57 
I write a custom server control with javascript
the javascript is as the following and is tested , which can use "Enter" key to go to the next textbox

------ test0205.html ------------------

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(':input').keydown(function(e){
if (e.keyCode == 13 ){

$(':input').eq($(':input').index($(this)) + 1).trigger('focus');

}
});
});
</script>
</head>
<body>

<input type="text" name="firstname"><br>
Last name:<br>
<input type="text" name="lastname">

</body>
</html>

--------------------------------------------------------------------


But after I put it into my server contro project (ServerControl6)
and use the control in the web page (Default4.aspx) , the code as follows

-------------------- ServerControl6.cs -------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ServerControl6
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:ServerControl6 runat=server></{0}:ServerControl6>")]
public class ServerControl6 : System.Web.UI.WebControls.TextBox
{
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
public string Text
{
get
{
String s = (String)ViewState["Text"];
return ((s == null)? "[" + this.ID + "]" : s);
}

set
{
ViewState["Text"] = value;
}
}

protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
string scriptKey = "TextBoxEnter" + this.UniqueID;
ClientScriptManager cs = Page.ClientScript;
Type cstype = this.GetType();
if (!cs.IsClientScriptBlockRegistered(scriptKey))
{
string scriptBlock =
@"<script language=""JavaScript"">
<!--
$(document).ready(function(){
$(':input').keydown(function(e){
if (e.keyCode == 13 ){
$(':input').eq($(':input').index($(this)) + 1).trigger('focus');

}
});
});
// -->
</script>";

cs.RegisterClientScriptBlock(cstype, scriptKey, scriptBlock);

}
}


}
}


-------------------- AssemblyInfo.cs -----------------------
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Web.UI;


[assembly: AssemblyTitle("ServerControl6")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ServerControl6")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]


[assembly: Guid("02a2c0e8-68f5-4df3-b8c2-97f433584357")]


[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TagPrefix("ServerControl6", "aspSample")]


-------- Default4.aspx ------------------------------

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>

<%@ Register assembly="ServerControl6" namespace="ServerControl6" tagprefix="aspSample" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style type="text/css">
#form1 {
height: 579px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

</head>
<body>
<form id="form1" runat="server">
<div style="height: 525px">

<br />
<aspSample:ServerControl6 ID="ServerControl61" runat="server"></aspSample:ServerControl6>
<br />
<br />
<aspSample:ServerControl6 ID="ServerControl62" runat="server"></aspSample:ServerControl6>
<br />
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" />

</div>
</form>
</body>
</html>
---------------------------------------------------------------------
I tried to save the html code generated by asp.net as a html file(render2016-1.html) which is the following

---------------- render2016-1.html ------------------



<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>

</title>

#form1 {
height: 579px;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

</head>
<body>
<form method="post" action="Default4.aspx" id="form1">

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="CoCWzO/vWYkNRBCpFbIQ3IPvm7ueZdcg7gaDU3S4YPnnHh6YhLHAUgVDIaTSe9kaEwNqnlScnHq/YYOhf5gw+s7Wu6bUynanqupEJH8WIzNkDwKd6PYNgPGXNfkR6Mgk" />


<script language="JavaScript">

</script><script language="JavaScript">

</script>


<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="44C02278" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="U2n4TbuH4IvEG/Bsq9RE7wS5fX5d/+Qb6Mh7sWlT0q4BldcSVq6R7yngmv2WKGXiMAOpblFJWUaqnXayL+azyfmb/UwOyyH57eegvf6lOVxY9j4GXrBoz8wSRk82espsW3DJ0rCLi48RAmK9xboMgunbb+oWfe6ScP1QWMsabqU=" />





<input name="ServerControl61" type="text" value="123" id="ServerControl61" />




<input name="ServerControl62" type="text" id="ServerControl62" />






<input type="submit" name="Button1" value="Button" id="Button1" />


</form>
</body>
</html>


---------------------------------------------------------------------
while I use the browser debug tool to run the code , there is a error message as below
---------------------------------------------------------------------
This page contains the following errors:
error on line 1 at column 2: StartTag: invalid element name
Below is a rendering of the page up to the first error.
---------------------------------------------------------------------
Is there anybody can tell me where is the problem ?
SuggestionRe: have a problem in custom control with javascript Pin
Kornfeld Eliyahu Peter15-Feb-16 20:06
professionalKornfeld Eliyahu Peter15-Feb-16 20:06 
QuestionTelerik TreeList Child Level Items are not retrievable by using FindItemByKeyValue method Pin
indian14312-Feb-16 16:53
indian14312-Feb-16 16:53 
Questionproper use of System.Web.HttpContext.Current.User Pin
jkirkerx12-Feb-16 12:56
professionaljkirkerx12-Feb-16 12:56 
AnswerRe: proper use of System.Web.HttpContext.Current.User [Not Solved but I get it now] Pin
jkirkerx13-Feb-16 13:53
professionaljkirkerx13-Feb-16 13:53 
SuggestionRe: proper use of System.Web.HttpContext.Current.User [Not Solved but I get it now] Pin
Richard Deeming15-Feb-16 2:26
mveRichard Deeming15-Feb-16 2:26 
GeneralRe: proper use of System.Web.HttpContext.Current.User [Not Solved but I get it now] Pin
jkirkerx15-Feb-16 7:15
professionaljkirkerx15-Feb-16 7:15 
QuestionASP .NET Custom Validation client side code not Working Pin
Member 1218422112-Feb-16 9:24
Member 1218422112-Feb-16 9:24 
AnswerRe: ASP .NET Custom Validation client side code not Working Pin
JHizzle14-Feb-16 23:36
JHizzle14-Feb-16 23:36 
GeneralRe: ASP .NET Custom Validation client side code not Working Pin
Member 1218422115-Feb-16 4:15
Member 1218422115-Feb-16 4:15 
GeneralRe: ASP .NET Custom Validation client side code not Working Pin
JHizzle16-Feb-16 1:07
JHizzle16-Feb-16 1:07 
AnswerRe: ASP .NET Custom Validation client side code not Working Pin
Wayne Stewart_17-Feb-16 3:41
Wayne Stewart_17-Feb-16 3:41 
Questionhow to implement unit measrements using asp.net webservices Pin
Member 1231070411-Feb-16 23:41
Member 1231070411-Feb-16 23:41 
AnswerRe: how to implement unit measrements using asp.net webservices Pin
Nathan Minier12-Feb-16 1:49
professionalNathan Minier12-Feb-16 1:49 
AnswerRe: how to implement unit measrements using asp.net webservices Pin
aarif moh shaikh15-Feb-16 19:59
professionalaarif moh shaikh15-Feb-16 19:59 
QuestionAccess the Public Property of User Control in the ASP.Net web farms page Pin
indian14310-Feb-16 14:01
indian14310-Feb-16 14:01 
AnswerRe: Access the Public Property of User Control in the ASP.Net web farms page Pin
Richard Deeming11-Feb-16 0:45
mveRichard Deeming11-Feb-16 0:45 
GeneralRe: Access the Public Property of User Control in the ASP.Net web farms page Pin
indian14312-Feb-16 13:01
indian14312-Feb-16 13:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.