मैंने क्लास लाइब्रेरी के अंदर सी # में एक कक्षा बनाई है और मैंने इस नियंत्रण को default.aspx में जोड़ा है, लेकिन मेरा कोड पेज_लोड ईवेंट को नहीं चलाता है। यहां कोड है:Page_Load UserControl में गोलीबारी नहीं कर रहा है
मैं गलत क्या कर रहा हूं?
पृष्ठ लोड होता है लेकिन पृष्ठ पर लेबल नहीं दिखाता है। मैंने बिना किसी त्रुटि के पेज पर नियंत्रण जोड़ा है। मैंने ईवेंट में पंजीकरण टैग जोड़ा है।
HTML टैग: <RandoIntegerControls:RandomIntegerControl ID="RandomIntegerControl1" runat="server"></RandoIntegerControls:RandomIntegerControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
namespace CSIMedia.WebControls
{
public class RandomIntegerControl : PlaceHolder
{
private Label _Label;
public RandomIntegerControl()
{
}
private void Page_Load(Object sender, EventArgs e)
{
this._Label = new Label();
this.Controls.Add(this._Label);
this._Label.Text = "Enter random values:";
}
}
}
Default.aspx पेज:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register TagPrefix="RandoIntegerControls" Assembly="CSIMedia.WebControls" Namespace="CSIMedia.WebControls"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<RandoIntegerControls:RandomIntegerControl ID="RandomIntegerControl1" runat="server"></RandoIntegerControls:RandomIntegerControl>
</div>
</form>
</body>
</html>
क्या आपने एएसपीएक्स फ़ाइल में अपने कस्टम नियंत्रण की .ascx फ़ाइल शामिल की है जो इसका उपयोग करता है? – skaz
नहीं मैंने इसे हटा दिया। मैंने कोई एसीएक्स फाइल नहीं बनाई है। मैंने इस वर्ग को class.cs फ़ाइल के रूप में बनाया है और इस पृष्ठ को केवल पृष्ठ पर जोड़ा है। लेकिन मैंने default.aspx पेज को वापस जोड़ा है और मुझे अभी भी इसके साथ कोई भाग्य नहीं है। – redoc01
क्या आप वह कोड दिखा सकते हैं जहां आपने पृष्ठ पर नियंत्रण जोड़ा था? – skaz