|
The register is the webform side of the dll.
<uc1:sample>
The code side is something like, ceSteps is the class name assigned to the program code you want to access.
Dim myCtrl As ceSteps = new ceSteps
ceSteps myCtrl = new ceSteps;
ceSteps *myCtrl = new ceSteps;
|
|
|
|
|
I kinda get what you're saying and I tried it, but it won't let me reference the class ceSteps as a namespace like I do when I import at the top of the page (say for my login code) and then reference an instance of a namespace. I've used the code below before in another app, honest, but it's not working and I'm stumped.
Dim myPnl As Panel = CType(CType(FindControl("ceSteps"), UserControl).FindControl("pnlStage1"), Panel)
myPnl.BackColor = System.Drawing.ColorTranslator.FromHtml("#dfdfdf")
|
|
|
|
|
I also thought it might be because I was missing the reference through the master/content relationship, but that wasn't it:
Dim myConPH As ContentPlaceHolder
myConPH = CType(FindControl("SSLmaster_ContentPlaceHolder1"), ContentPlaceHolder)
Dim myPnl As Panel = CType(CType(myConPH.FindControl("ceSteps"), UserControl).FindControl("pnlStage1"), Panel)
|
|
|
|
|
I wasn't able to see your user control.
With user controls, like server controls, you don't use the code behind pages on the webform to interact with them. Instead, you write more code in your user control.
So just register the control in the webform like you did. Then if you want to do something in page.load, you add an override to your user control.
Public Class MyControl
Private lbl_Website_Name As Label
Protected overrides Sub OnInit(ByVal e as System.EventArgs)
controls.clear
lbl_WebsiteName = New Label
With lbl_Website_Name
End With
Controls.Add(lbl_Website_name)
End Sub
Protected overrides Sub OnLoad(ByVal e As System.EventArgs)
Do you stuff.
lbl_Website_Name.txt = sWebsiteName
End Sub
This will append to the current page.load on the web form, and operate identical to page load.
You can call the control by the name assigned,
|
|
|
|
|
 Sorry, that won't work for me - I need to do so from the child webpage. Let me try and be a little more precise, maybe that will help. I really think it's something to do with master/child since I was able to successfully reference one when not using the master.
Master:
<%@ Master Language="VB" CodeFile="SSLmaster.master.vb" Inherits="master" EnableTheming="true" %>
<body>
<form id="form1" runat="server" enableviewstate="true"><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
yahda, yahda, yahda...
Child:
<%@ Page Title="yahda" Theme="SSL" Language="VB" MasterPageFile="~/inc/SSLmaster.master" AutoEventWireup="false" CodeFile="zdetail1.aspx.vb" Inherits="calendar_zdetail1" %>
<%@ Register Src="~/inc/ceSteps.ascx" TagName="ceSteps" TagPrefix="uc1" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
UserControl:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="ceSteps.ascx.vb" Inherits="inc_ceSteps" %>
<asp:Panel runat="server" ID="Panel1" > Step 1 </asp:Panel>
CodeBehind of Child:
First Stab (successful on page without Master):
Dim myPnl As Panel = CType(CType(FindControl("ceSteps"), UserControl).FindControl("pnlStage1"), Panel)
myPnl.BackColor = System.Drawing.ColorTranslator.FromHtml("#dfdfdf")
Second Stab (and many more variations)
Dim myConPH As ContentPlaceHolder
myConPH = CType(FindControl("SSLmaster_ContentPlaceHolder1"), ContentPlaceHolder)
Dim myPnl As Panel = CType(CType(myConPH.FindControl("ceSteps"), UserControl).FindControl("Panel1"), Panel)
myPnl.BackColor = System.Drawing.ColorTranslator.FromHtml("#dfdfdf")
|
|
|
|
|
Well, you use css to change the background color of the panel.
But I don't when you want to change the color.
On postback, in the server, or when creating the control
If you want to remove the existing css
MyPnl.Style.Remove(HtmlTextWriterStyle.backgroundColor)
If you want to add a style
MyPnl.Style.Add(HtmlTextWriterStyle.backgroundColor, "#dfdfdf")
|
|
|
|
|
 Sorry, that won't work for me if I can't reference the control to change the style. Understand the problem now? Let me try and be a little more precise, maybe that will help. I really think it's something to do with master/child since I was able to successfully reference one when not using the master.
Master:
<%@ Master Language="VB" CodeFile="SSLmaster.master.vb" Inherits="master" EnableTheming="true" %>
<body>
<form id="form1" runat="server" enableviewstate="true"><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
yahda, yahda, yahda...
Child:
<%@ Page Title="yahda" Theme="SSL" Language="VB" MasterPageFile="~/inc/SSLmaster.master" AutoEventWireup="false" CodeFile="zdetail1.aspx.vb" Inherits="calendar_zdetail1" %>
<%@ Register Src="~/inc/ceSteps.ascx" TagName="ceSteps" TagPrefix="uc1" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
UserControl:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="ceSteps.ascx.vb" Inherits="inc_ceSteps" %>
<asp:Panel runat="server" ID="Panel1" > Step 1 </asp:Panel>
CodeBehind of Child:
First Stab (successful on page without Master):
Dim myPnl As Panel = CType(CType(FindControl("ceSteps"), UserControl).FindControl("pnlStage1"), Panel)
myPnl.BackColor = System.Drawing.ColorTranslator.FromHtml("#dfdfdf")
Second Stab (and many more variations)
Dim myConPH As ContentPlaceHolder
myConPH = CType(FindControl("SSLmaster_ContentPlaceHolder1"), ContentPlaceHolder)
Dim myPnl As Panel = CType(CType(myConPH.FindControl("ceSteps"), UserControl).FindControl("pnlStage1"), Panel)
myPnl.BackColor = System.Drawing.ColorTranslator.FromHtml("#dfdfdf")
|
|
|
|
|
I'm looking at your markup code, I understand the markup code,
But I have no idea what your trying to achieve. What the steps are, the purpose of changing the color, when and where.
My interpretation is that you want to find the asp.net ID of the panel control in the child webform, make a handle to it, and change the background color of the panel.
Not the Answer but here's how it works::
When adding a master page, the id of the control will be prefixed with CT_100_ or CT100_
That's the only difference between the 2 scenarios. MasterPage will also start to auto ID your controls, if you don't assign a ID manually. In other words, when you master page, asp.net will automatically fix all your control id's so it can find and track the controls, and disregards your need to find them. Every control has to have a unique ID, and no one can be the same.
So myPnl becomes CT_100_myPnl if you assign the ID atribute. If you don't assign the ID attribute, asp.net will assign a senquential auto naming ID code to the control object, and find control will never find it.
Naming Practices:
When naming a control in a user control, you can use ID = [ID] & "_myPnl", which produces CT_100_ceSteps_myPnl
This will stop the auto id's of your controls, so you actually are in charge of naming your objects.
Diagnostics:
So look at the html that was created by the server in the browsers source, in both with and without master page, and write down the control id or each one. And put that exact name in find control. Oh, ever the placeholder name will change as well.
I haven't used find control in years, and I abandoned the use of it, and have forgotten how to use it in master pages. Over the years I learned how to access any object on the page, at the right time and place, so that's not an issue for me anymore.
|
|
|
|
|
The problem is that UserControl has no pn1Stage1 member...
In the first line, you're specifying that myCtrl is of type UserControl. In order to access a specific property of YOUR user control, you need a variable of that type...something like...
Dim myCtrl as MyControlType = CType(FindControl("ceSteps", MyControlType))
The trick is that FindControl returns a Control type, which you then cast to the correct type.
C# has already designed away most of the tedium of C++.
|
|
|
|
|
Thanks for the reply, Richard. Tried it, but no go. I still think it has something to do with those pesky Master pages. Again, the one I've been using without Master Pages works fine... Got the same error.
Dim myCtrl As UserControl = CType(FindControl("ceSteps1"), UserControl)
Dim myPnl As Panel = CType(myCtrl.FindControl("pnlStage1"), Panel)
myPnl.BackColor = Drawing.Color.Azure
|
|
|
|
|
I found this, and I kinda get what they're saying, but I can't get it to work either.
tip18843
Protected MyCtl As Panel
Private Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Init
MyCtl = DirectCast(FindControl("pnlStage1"), Panel)
End Sub
Protected Sub btnStep2b_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnStep2b.Click
MyCtl.BackColor = Drawing.Color.Azure
End Sub
|
|
|
|
|
Since I am having so many problems with using a detailsview 2010 control, I am going to convert my logic to use a formview control instead. Thus can you tell me if there is a referenceon on how to convert and/or copy detailsview code to formsview code?
Basically I am going to take the itemtemplate and editiemtemplates and hopefully use them in the formwview control.
I will place the update and clear buttons outside of the formsview control but on the webform page. Thus to be able to update the data on the buttons outside of the the formsview would I use a updateitem method or some other method?
|
|
|
|
|
Good Day Fellows
i have a Dynamic Questionnaire that is created using dynamic data from the Database. My data in the Database contains the fields like
QuestionID - Primary key
Question - The Question Text
Answer - The Answer
Required - This is a Validation , i used this to enable the Required validator in asp.net
DataType - This is the Datatype, it can be a Heading also.
ReadOnly - This check if that Question is a Read-only , This happens most of the time , when it is a Calculated Field, meaning its values depends on other fields values.
Order - This is the order the Questions will appear
Section - This is the section, So the Questions are Grouped. Normaly in Page1 you will have Questions for Section 1.......
Deleted- This is a bit Field , its either 1 or 0 , 1 is active, so this helps be to Filter only active Questions
QuestionType- This is the Type of Control the Data should be Presented with, It can be a Dropdown ,checkbox or textbox..
QT_ID - There can be many Templates of the Question , this makes sure we use the Correct Template for the Questionnaire
So with this kind of Data , i want to use know , what asp.net Control can i use to achieve this.
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
Hi,
In master page i have header,menu,content placeholder and footer.On click of each menu items the header and footer are refreshing.i had enclosed the code and css file.
The header and footer must be fixed only the contents must change.Need help.
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Main.master.cs" Inherits="Main" %>
<%@ Register Src="~/Menu.ascx" TagName="HeaderMenu" TagPrefix="uc1" %>
<!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>Untitled Page</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<table border="0" cellspacing="0" cellpadding="0" width="100%" align="center">
<%-- <tr>
<td>
<table id="Table1" border="0" cellpadding="0" cellspacing="0">
<tr>
<td id="headerleft">
<img alt="left" src="Images/PortalBanner_Left.gif"/>
</td>
<td id="Td1" class="bannerimg">
<img alt="" src="Images/Logon_Header_Image_SCF3.jpg" style="width:450px;height:50px" />
</td>
<td id="headerright">
<img alt="right" src="Images/PortalBanner_right.gif" />
</td>
</tr>
</table>
<table class="bannerimg" border="0" width="100%">
<tr style="font-size:small; width: auto; ">
<td style="text-align: left; padding-left: 10px">
<asp:Label ID="lblWelcome" runat="server" Text="Welcome " CssClass="hrefClass"></asp:Label>
<asp:Label ID="lblUser" runat="server" CssClass="hrefClass"></asp:Label>
</td>
<td style="width: auto; text-align: right;">
<asp:LinkButton ID="lnHome" runat="server" class="hrefClass" CausesValidation="false" >Home</asp:LinkButton>
<asp:LinkButton ID="lnLogout" runat="server" class="hrefClass"
CausesValidation="false" >Logout</asp:LinkButton>
</td>
</tr>
</table>
</td>
</tr>--%>
<div id="header">
<p><a href="http://blog.dampee.be/">Techspace</a>
<img src="Images/Logon_Header_Image_SCF3.jpg" alt=""/>
</p>
<span>About technology</span>
</div>
<tr>
<td colspan="3">
<div id="menu">
<uc1:HeaderMenu id="HeaderMenu1" runat="server"></uc1:HeaderMenu>
</div>
</td>
</tr>
<tr>
<td colspan="3" style="vertical-align: top; height:600px; width: 100%; background-color: White;">
<div id="content">
<div class="middle_blk">
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</div>
</td>
</tr>
</table>
<div id="footer">
<div class="footer_blk">
<div class="middle_blk">
<img src="Images/PoweredByASPNET.gif" alt="Powered by ASP.NET!" />
</div>
</div>
</div>
</form>
</body>
</html>
body{padding:0;margin:0;background:url(http://imgs1.2000shareware.com/contentbase/body_bg.gif) repeat-x;font:12px/18px Arial,Helvetica,sans-serif;color:#3a3e41}h1,h2,h3,h4,h5{font-weight:normal;text-align:center;font-family:Georgia,Arial,Helvetica,sans-serif}h1{margin:0 0 13px;font-size:17px;line-height:25px}h1.title{background:url(http://imgs1.2000shareware.com/contentbase/page_title.gif) no-repeat center bottom;padding:0 0 11px}h2{margin:0;font-size:19px;line-height:35px}h3{margin:0 0 13px;font-size:17px;line-height:25px}h3.title{background:url(http://imgs1.2000shareware.com/contentbase/page_title.gif) no-repeat center bottom;padding:0 0 11px}h4{font-size:13px;line-height:13px;font-family:Arial,Helvetica,sans-serif;text-align:left;margin:0 0 2px}p{margin:0 0 25px}a{text-decoration:none;color:#0058bc;outline:none}a:hover{text-decoration:underline;color:#cc2a7d}img{border-style: none;
border-color: inherit;
border-width: medium;
height: 80px;
}ul,ol,dl{list-style:none;padding:0;margin:0}input,select,textarea{font:12px/18px Arial,Helvetica,sans-serif;color:#686f76}#wrapper{min-width:996px}#header{height:132px;padding-top:12px;background:url(http://imgs1.2000shareware.com/contentbase/header_bg.jpg) no-repeat center top}.middle_blk{width:996px;margin:0 auto}#header h1{float:left;margin:0 0 8px}#header h1 span{display:none}#header .search{width:189px;height:19px;float:right;margin-top:18px;padding:6px 11px 0 10px;background:url(http://imgs1.2000shareware.com/contentbase/search_blk.png) no-repeat}#header .search input{float:left;border:none;padding:0;width:160px;background:none}#header .search input.search_btn{float:right;width:14px;height:13px;background:url(http://imgs1.2000shareware.com/contentbase/search_btn.gif) no-repeat;cursor:pointer}#header ul li{float:left}#header ul li a{display:block;float:left;padding:3px 16px 0;height:38px;font:15px/35px Georgia,Arial,Helvetica,sans-serif;color:#000}#header ul li a:hover,#header ul li.active a{background-color:#cc2a7d;color:#fff;text-decoration:none}#content{background:url(http://imgs1.2000shareware.com/contentbase/content_bg.gif) repeat-x;padding:18px 0 4px;overflow:hidden}#content .col_left{width:210px;float:left}#content .topbox{background:url(http://imgs1.2000shareware.com/contentbase/col_top_box.gif) no-repeat}#content .topbox h2{background:url(http://imgs1.2000shareware.com/contentbase/col_box_title.gif) no-repeat center bottom;padding:14px 5px 4px;color:#cc2a7d}#content .cenbox{background:url(http://imgs1.2000shareware.com/contentbase/col_cen_box.gif) repeat-y;margin-bottom:11px}#content .botbox{background:url(http://imgs1.2000shareware.com/contentbase/col_bot_box.gif) no-repeat center bottom;padding:0 4px 9px}#content ul.categories{padding-top:3px}#content ul.categories li{background:url(http://imgs1.2000shareware.com/contentbase/category_tab.gif) no-repeat;padding:0 8px 8px 12px}#content ul.categories li a.title{float:left;height:25px;background:url(http://imgs1.2000shareware.com/contentbase/category_tab_title.gif) no-repeat 100% 0;padding-right:26px;color:#000;font-size:13px;font-weight:bold;line-height:30px}#content ul.categories li span.count{float:right;color:#686f76;line-height:30px}#content ul.categories li p{margin:0;clear:both;padding-top:2px;line-height:15px}#content ul.categories li.first{background:url(http://imgs1.2000shareware.com/contentbase/category_tab_first.gif) no-repeat}#content ul.categories li.first a.title{background-position:100% -25px}#content ul.categories li.last{background:url(http://imgs1.2000shareware.com/contentbase/category_tab_last.gif) no-repeat}#content .col_cen{width:544px;padding:0 15px;float:left}#content .col_cen .soft_list{overflow:hidden;padding:0 0 20px}#content .col_cen .soft_list .img_blk{float:left;width:40px}#content .col_cen .soft_list .desc{width:504px;float:right}#content .col_cen.big_pic .img_blk{width:150px}#content .col_cen.big_pic .desc{width:394px}#content .col_cen.numbers .img_blk{width:52px;padding:4px 0 0}#content .col_cen.numbers .img_blk strong{font-size:18px}#content .col_cen.numbers .desc{width:492px}#content .col_cen .soft_list .desc p{margin:0}#content .col_right{width:210px;float:right}#content ul.list{background:#fff url(http://imgs1.2000shareware.com/contentbase/col_box_last.gif) no-repeat left bottom;padding-bottom:10px}#content ul.list li{background:url(http://imgs1.2000shareware.com/contentbase/grey_dot.png) no-repeat 12px 10px;padding:0 7px 0 32px;border-bottom:1px solid #f0f3f6;border-top:none}#content ul.list li.last{border:none}#content ul.list li p{margin-bottom:5px}#content ul.list li a{line-height:25px}#content ul.new_press li{padding:4px 7px 4px 32px}#content ul.new_press li a{line-height:15px}#content p.breadcrumb{text-align:center;margin-bottom:20px}#content p.breadcrumb a{margin:0 5px}#content p.breadcrumb img{vertical-align:middle}#content p.btnblk{text-align:center;overflow:hidden;margin:22px 0 30px}#content p.btnblkNomar{text-align:center;overflow:hidden;margin:0}#content p.btnblk a.btn{float:none;display:inline-block;margin-right:15px}#content .tbl_info{width:260px;float:left;background:url(http://imgs1.2000shareware.com/contentbase/tbl_info_cen.gif) repeat-y;margin-bottom:35px}#content .tbl_top{background:url(http://imgs1.2000shareware.com/contentbase/tbl_info_top.gif) no-repeat}#content .tbl_bot{background:url(http://imgs1.2000shareware.com/contentbase/tbl_info_bot.gif) no-repeat left bottom;padding:0 1px}#content .softprew{float:left;margin:0 13px 5px 0}#content .tbl_top p{margin:0;border-bottom:1px solid #f0f3f6;line-height:30px;overflow:hidden}#content .tbl_top p span{float:left}#content .tbl_top p span.left{width:97px;padding-left:11px}#content .tbl_top p span.right{width:140px}#content .tbl_top p big{font-size:14px;color:#cc2a7d}#content .tab_mid p big{font-size:14px;color:#cc2a7d}#content .tbl_top p a{color:#3a3e41;text-decoration:underline}#content .tab_mid p a{color:#3a3e41;text-decoration:underline}#content p.softdesc{line-height:21px}#content .col_cen .pages{margin:10px 0 19px 0;float:left;width:100%;font-size:13px;line-height:13px}#content .col_cen .pages_left{font-weight:bold;float:left;margin:0 0 0 6px;display:inline}#content .col_cen .pages_left_btm{float:left;margin:0 0 0 6px}#content .col_cen .pages_right ul{float:right}#content .col_cen .pages_right ul li{display:inline;vertical-align:middle}#content .col_cen .pages_right ul li a,#content .col_cen .pages_right ul li a img,#content .col_cen .pages_right ul li span{padding:0 3px}#content .col_cen .pages_right ul li a:hover{color:#cc2a7d;text-decoration:underline}#content .col_cen .pages_right ul li span{color:#cc2a7d;font-weight:bold}#content .col_cen .pages_right img{vertical-align:middle}li.last{border:none}#content .col_cen .col_cen_box{width:507px;margin:7px 0 19px 6px;float:left}#content .col_cen .col_cen_box h4 a{font-weight:bold;font-size:13px;line-height:18px;color:#0058bc;margin-bottom:5px}#content .col_cen .col_cen_box h4 a:hover{color:#cc2a7d}#content .col_cen .col_cen_box span.date{font-weight:bold;color:#3a3e41}#content .col_cen .col_cen_box p{margin:5px 0;font-size:12px}#content .col_cen .col_cen_txt{float:left;margin:20px 0 0 0;width:100%}#content .col_cen .col_cen_txt p{margin:0 10px 30px 6px;font:12px/20px Arial,Helvetica,sans-serif;color:#686f76}#content .tab_top{background:url(http://imgs1.2000shareware.com/contentbase/table_top.png) no-repeat center top;width:535px;height:4px;float:left;font-size:1px}#content .tab_mid{background:url(http://imgs1.2000shareware.com/contentbase/table_mid.png) repeat-y center top;width:535px;float:left}#content .tab_mid p{border-bottom:1px solid #f0f3f6;line-height:30px;margin:0 auto;width:531px;overflow:hidden}#content .tab_mid p span{float:left}#content .tab_mid p span.left{padding-left:11px;width:97px}#content .tab_mid p span.left2{padding-left:11px;width:530px;background-color:#f9fafa}#content .tab_mid p span.right{padding-left:5px;width:410px}#content .tab_btm{background:url(http://imgs1.2000shareware.com/contentbase/table_btm.png) no-repeat center top;width:535px;height:4px;float:left}.footer_categories{background:#f0f3f6 url(http://imgs1.2000shareware.com/contentbase/footer_category_bg.gif) repeat-x;overflow:hidden;padding:10px 0}.footer_categories dl{width:190px;float:left}.footer_categories dt{font:15px/35px Georgia,Arial,Helvetica,sans-serif}.footer_categories dt a{color:#000}.footer_categories dl dd{background:url(http://imgs1.2000shareware.com/contentbase/grey_dot.png) no-repeat 0 7px;padding:0 0 0 20px;margin:0;line-height:20px}#footer{background:url(http://imgs1.2000shareware.com/contentbase/footer_bg.gif) repeat-x;font-size:11px;line-height:30px;color:#fff}#footer .footer_blk{background:#a62166 url(http://imgs1.2000shareware.com/contentbase/footer_blk.jpg) no-repeat center top;overflow:hidden}#footer p.copyright{float:left;margin:0;width:435px;line-height:normal;padding:8px 0 14px}#footer p.copyright.center{float:none;width:100%;text-align:center;line-height:14px;padding:0}#footer ul{float:left}#footer ul li{display:inline;margin-right:8px}#footer ul li a{color:#fff;margin-right:10px}#footer ul li a:hover{color:#fff;text-decoration:underline}a.btn,a.btn.pink{display:block;width:112px;height:29px;float:left;background-image:url(http://imgs1.2000shareware.com/contentbase/btn_bg.gif);background-position:0 0;background-repeat:no-repeat;text-transform:capitalize;font:15px/29px Georgia,Arial,Helvetica,sans-serif;color:#3a3e41}a.btn.pink{background-position:0 -29px;color:#fff}.clear{clear:both}.fleft{float:left!important}.fright{float:right!important}.nomar{margin:0!important}.acenter{text-align:center!important}.blue{color:#0058bc}.nobrd{border:none}#memo_message{background-color:#f0f3f6;border:1px solid #686f76}
Thanks
S.Guhananth
|
|
|
|
|
A master page is just a common "template" that is used by different pages for the purpose of reusability.If you dont want refresh it ,you can use partially updation by update panel.
Ajax Update Panel.
or You can use instead of masterpage
use IFrame.
|
|
|
|
|
The master pages solves an old issue with classic asp, php, and just plain html in which developers wanted to create a consistent header and footer. So before in the old days, you had to sort of slip your header and footer file into your content file, or vice versus, I don't remember which.
if you place linkbuttons on your master page, when you click them they will generate a postback like they are suppose to. They are not refreshing, but are sending the form back to the server for processing.
Now with just plain html, you can get rid of the form tag, and the page will not postback, because there is no form data. But ASP.Net requires a form tag on all pages.
So if you want to confine the postback to just the content, wrap the content in an update panel, and make a trigger for each button you need to issue a small async postback to the server, in which only the content in the update panel will make the round trip to the server and back.
You can rid of the linkbuttons, for they are not needed, unless you need to calculate something before the action. Use a Hyperlink if you want to send to another page.
<td style="width: auto; text-align: right;">
<asp:Hyperlink ID="lnHome" runat="server" class="hrefClass">Home</asp:Hyperlink> 
<asp:Hyperlink ID="lnLogout" runat="server" class="hrefClass">Logout</asp:Hyperlink>
</td>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
<asp:updatepanel id="updatePanel_Content1" runat="server">
<asp:contentTemplate>
</asp:contentTemplate>
// add a asyncpostback trigger
</asp:updatepanel>
</asp:ContentPlaceHolder>
|
|
|
|
|
Hi,
If i place a header image and footer text the whole page refreshes on click of menu.How to resolve this.
Guhananth.S
|
|
|
|
|
I need a more precise description. Click on what type of control, in what area of the page?
|
|
|
|
|
Hi,
I have a master page.There i had added an user control ie Menu.ascx.I had placed a header image,then user control,then content placeholder ie Child page and footer.
On click ok menu or submenu,the whole page refreshers.
I want the header and footer to be fixed.How to implement that,I had tried always.
Suggest some url or working sample.
u can refer my code.
Thanks
S.Guhananth.
|
|
|
|
|
Hi,
I used the following code to edit a wcf message using message inspector.
MemoryStream ms = new MemoryStream();
Encoding encoding = Encoding.UTF8;
XmlWriterSettings writerSettings = new XmlWriterSettings { Encoding = encoding };
XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(ms);
message.WriteBodyContents(writer);
writer.Flush();
string messageBodyString = encoding.GetString(ms.ToArray());
messageBodyString = messageBodyString.Replace("<n1>100</n1>", "<n1>200</n1>");
ms = new MemoryStream(encoding.GetBytes(messageBodyString));
XmlReader bodyReader = XmlReader.Create(ms);
Message originalMessage = message;
message = Message.CreateMessage(originalMessage.Version, null, bodyReader);
message.Headers.CopyHeadersFrom(originalMessage);
Actual body of the message was like
<s:Body u:Id="_0">
<Add xmlns="http://Microsoft.Samples.AdvancedFilters">
<n1>100</n1>
<n2>15.99</n2>
</Add>
</s:Body>
I wanted to change the value in the
<n1> tag from 100 to 200. But after executing the method
Message.CreateMessage(originalMessage.Version, null, bodyReader) , the body is shown like
<s:Body>... stream ...</s:Body>
|
|
|
|
|
It is in my opinion that you going about the process backwards.
When working with xml, no matter what the packaging is, wsdl, etc, you have to build the framework needed to write the xml file, edit, update, add, delete elements and child elements first.
Then you need to write the code needed to read and write it to the disk drive.
Now memory streams come into play, with memory stream, you can create a brand new xml file, store it in a memory stream, and transmit it to another server, or just send it to another function without ever touching the disk drive. While in memory, you can stuff it into your xml editor, modify it, store it back in the memory stream, and send it back out.
I use xsd to create a model of my xml, and compile it into a class object using xsd.exe /classes /vb /sample.sml to create sample.vb.
Then I use XMLTextWriter, to load up the sample.vb. The class wires up the xml structure, so an edit is as simple as sample.n1 = 200
|
|
|
|
|
|
This is a xsd template. I write them in Liquid Studio, but now I can write them from scratch. This one is very simple. I don't export the xml as a memory stream, but I do hold the entire xml in server memory, and when done, I write it back to the disk drive. The xsd, xml, program code all matches together. This is the fastest xml in asp.net. It is capable of doing 10 transactions per second, and I have 1 complex file with over 20,000 records in it, that can update really fast. This is how you write xml for DHL Express, UPS, Chase Payment Tech, PayPal, and any other web service that requires XML. It may be very difficult to comprehend at first, but I did all the heavy lifting for you.
You can save this as Sale_Messenger.xsd
="1.0"="utf-8"
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Sale_Messenger">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="unbounded" name="Registered_Members">
<xs:complexType>
<xs:all>
<xs:element name="Name" type="xs:string" />
<xs:element name="EmailAddress" type="xs:string" />
</xs:all>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Version" type="xs:string" />
<xs:attribute name="CreationDate" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:schema>
Now I run the xsd using LS, to confirm it makes a valid xml file.
Sale_Messenger.xml
="1.0"="utf-8"
-
- <Notification xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Sep-WSDLS\TransactionNotifications\TransactionNotifications.xsd" Version="string" CreationDate="string">
- <Registered_Members>
<Name>string</Name>
<EmailAddress>string</EmailAddress>
</Registered_Members>
- <Registered_Members>
<Name>string</Name>
<EmailAddress>string</EmailAddress>
</Registered_Members>
- <Registered_Members>
<Name>string</Name>
<EmailAddress>string</EmailAddress>
</Registered_Members>
- <Registered_Members>
<Name>string</Name>
<EmailAddress>string</EmailAddress>
</Registered_Members>
</Notification>
So I have 2 files, Sales_Messenger.xsd, and Sales_Messenger.xml
I use xsd.exe on the xsd file - xsd.exe /vb /classes Sales_Messenger.xsd to produce a Sales_Messenger.vb class. Now I import the class into my project. You can find xsd.exe in VS 2005, 09, 10. Make the file and copy it into your project, include it.
Then I wrote a new class, to create a new file, update, and delete.
Private Sub Add_NewMember()
Dim FirstRecordFlag As Boolean = False
Dim Success As Boolean = True
Dim ContactName As String = False
Dim SecureContactName As String = Nothing
Dim Master_ContactName As String = Nothing
Dim ContactEmailAddress As String = Nothing
Dim SecureEmailAddress As String = Nothing
ContactName = txt_Setup_SalesMessenger_SendName_Field.Text.Trim
ContactEmailAddress = txt_Setup_SalesMessenger_SendEmail_Field.Text.Trim
SecureContactName = ice5commerce.common.EncryptDecrypt.Encrypt(ContactName)
SecureEmailAddress = ice5commerce.common.EncryptDecrypt.Encrypt(ContactEmailAddress)
Dim DataLocation As String = Nothing
DataLocation = Context.Server.MapPath("~/App_Data/CompanyInfo/Messenger.xml")
'XML Data routines go here
Dim request_serializer As New XmlSerializer(GetType(Sale_Messenger))
AddHandler request_serializer.UnknownNode, AddressOf serializer_UnknownNode
AddHandler request_serializer.UnknownAttribute, AddressOf serializer_UnknownAttribute
Dim Reader As XmlTextReader = Nothing
Dim XmlRequest As New Sale_Messenger
Try
Reader = New XmlTextReader(DataLocation)
XmlRequest = CType(request_serializer.Deserialize(Reader), Sale_Messenger)
Reader.Close()
Reader = Nothing
Catch ex As Exception
FirstRecordFlag = True
End Try
Try
If FirstRecordFlag = True Then
Dim MyMembers_0 As Sale_MessengerRegistered_Members = New Sale_MessengerRegistered_Members
MyMembers_0.Name = SecureContactName
MyMembers_0.EmailAddress = SecureEmailAddress
Dim MyMembers() As Sale_MessengerRegistered_Members = {MyMembers_0}
'Now Lets Write out the file as a MemoryStream
Dim serializer As XmlSerializer
serializer = New XmlSerializer(GetType(Sale_Messenger))
Dim XmlResponse As New Sale_Messenger
XmlResponse.Version = "1.4.2"
XmlResponse.CreationDate = DateTime.Now.ToString("yyyy-MM-dd")
XmlResponse.Registered_Members = MyMembers
'Now we have to write out a file for certification
Dim response_serializer As XmlSerializer = Nothing
response_serializer = New XmlSerializer(GetType(Sale_Messenger))
Dim response_writer As StreamWriter = Nothing
response_writer = New StreamWriter(DataLocation)
response_serializer.Serialize(response_writer, XmlResponse)
response_writer.Close()
response_writer = Nothing
request_serializer = Nothing
serializer = Nothing
Else
Dim MyMembers() As Sale_MessengerRegistered_Members
Dim MyMembers_Length As Integer = 0
MyMembers = XmlRequest.Registered_Members
MyMembers_Length = MyMembers.Length
Array.Resize(MyMembers, MyMembers_Length + 1)
MyMembers(MyMembers_Length) = New Sale_MessengerRegistered_Members
MyMembers(MyMembers_Length).Name = SecureContactName
MyMembers(MyMembers_Length).EmailAddress = SecureEmailAddress
'Now Lets Write out the file as a MemoryStream
Dim serializer As XmlSerializer
serializer = New XmlSerializer(GetType(Sale_Messenger))
Dim XmlResponse As New Sale_Messenger
XmlResponse.Version = "1.4.2"
XmlResponse.CreationDate = DateTime.Now.ToString("yyyy-MM-dd")
XmlResponse.Registered_Members = MyMembers
'Now we have to write out a file for certification
Dim response_serializer As XmlSerializer = Nothing
response_serializer = New XmlSerializer(GetType(Sale_Messenger))
Dim response_writer As StreamWriter = Nothing
response_writer = New StreamWriter(DataLocation)
response_serializer.Serialize(response_writer, XmlResponse)
response_writer.Close()
response_writer = Nothing
request_serializer = Nothing
serializer = Nothing
End If
Catch ex As Exception
Success = False
Admin_Standard.Admin_PCI_Transction.Insert_PCI_Transaction("Display_SU_Sale_Messenger.vb", "MESSENGER", "ADD", ContactName, False)
End Try
If Success = True Then
txt_Setup_SalesMessenger_SendEmail_Field.Text = ""
txt_Setup_SalesMessenger_SendName_Field.Text = ""
txt_Setup_SalesMessenger_SendEmailConfirm_Field.Text = ""
Admin_Standard.Admin_PCI_Transction.Insert_PCI_Transaction("Display_SU_Sale_Messenger.vb", "MESSENGER", "ADD", ContactName, True)
End If
End Sub
Private Sub Delete_Member()
Dim Name As String = Nothing
Dim SecureName As String = Nothing
Dim DeleteName As String = Nothing
Dim SecureDeleteName As String = Nothing
If lb_SalesMessenger_ContactList_Field.SelectedIndex > -1 Then
Dim idx As Integer = 0
SecureDeleteName = lb_SalesMessenger_ContactList_Field.SelectedValue
DeleteName = ice5commerce.common.EncryptDecrypt.Decrypt(SecureDeleteName)
Dim DataLocation As String = Nothing
DataLocation = Context.Server.MapPath("~/App_Data/CompanyInfo/Messenger.xml")
'XML Data routines go here
Dim request_serializer As New XmlSerializer(GetType(Sale_Messenger))
AddHandler request_serializer.UnknownNode, AddressOf serializer_UnknownNode
AddHandler request_serializer.UnknownAttribute, AddressOf serializer_UnknownAttribute
Dim Reader As XmlTextReader = New XmlTextReader(DataLocation)
Dim XmlRequest As New Sale_Messenger
XmlRequest = CType(request_serializer.Deserialize(Reader), Sale_Messenger)
Reader.Close()
Reader = Nothing
Dim MyMembers() As Sale_MessengerRegistered_Members
Dim MyMembers_Length As Integer = 0
MyMembers = XmlRequest.Registered_Members
MyMembers_Length = MyMembers.Length
Dim TestName As String = Nothing
Dim SecureTestName As String = Nothing
Dim SecureEmailAddress As String = Nothing
Dim ResizeArray_Flag As Boolean = False
Dim New_MyMembers() As Sale_MessengerRegistered_Members = MyMembers
Array.Resize(New_MyMembers, MyMembers.Length - 1)
Dim New_MyMembers_Length As Integer = New_MyMembers.Length
Dim jdx As Integer = 0
For idx = 0 To MyMembers_Length - 1
SecureTestName = MyMembers(idx).Name
SecureEmailAddress = MyMembers(idx).EmailAddress
TestName = ice5commerce.common.EncryptDecrypt.Decrypt(SecureTestName)
If Not String.Compare(TestName, DeleteName, True) = 0 Then
New_MyMembers(jdx).Name = SecureTestName
New_MyMembers(jdx).EmailAddress = SecureEmailAddress
jdx += 1
End If
idx += 1
Next
'Now Lets Write out the file as a MemoryStream
Dim serializer As XmlSerializer
serializer = New XmlSerializer(GetType(Sale_Messenger))
Dim XmlResponse As New Sale_Messenger
XmlResponse.Version = "1.4.2"
XmlResponse.CreationDate = DateTime.Now.ToString("yyyy-MM-dd")
XmlResponse.Registered_Members = New_MyMembers
'Now we have to write out a file for certification
Dim response_serializer As XmlSerializer = Nothing
response_serializer = New XmlSerializer(GetType(Sale_Messenger))
Dim response_writer As StreamWriter = Nothing
response_writer = New StreamWriter(DataLocation)
response_serializer.Serialize(response_writer, XmlResponse)
response_writer.Close()
response_writer = Nothing
request_serializer = Nothing
serializer = Nothing
Load_ListBox()
Admin_Standard.Admin_PCI_Transction.Insert_PCI_Transaction("Display_SU_Sale_Messenger.vb", "MESSENGER", "DELETE", DeleteName, True)
End If
End Sub
Private Function Does_SalesMessenger_XMLExist() As Boolean
Dim Context As HttpContext = HttpContext.Current
Try
Dim FileExist As Boolean = False
Dim DataLocation As String = Nothing
DataLocation = Context.Server.MapPath("~/App_Data/CompanyInfo/Messenger.xml")
Dim f As New IO.FileInfo(DataLocation)
If f.Exists = True Then
FileExist = True
Else
FileExist = False
End If
f = Nothing
Return FileExist
Catch ex As Exception
Record_Admin_Setup_Errors(ex.Message.ToString, ex.StackTrace.ToString)
End Try
Context = Nothing
End Function
Protected Sub serializer_UnknownNode(ByVal sender As Object, ByVal e As XmlNodeEventArgs)
Dim Context As HttpContext = HttpContext.Current
'Context.Response.Write("Unknown Node:" & e.Name & ControlChars.Tab & e.Text)
End Sub
Protected Sub serializer_UnknownAttribute(ByVal sender As Object, ByVal e As XmlAttributeEventArgs)
Dim Context As HttpContext = HttpContext.Current
Dim attr As System.Xml.XmlAttribute = e.Attr
'Context.Response.Write("Unknown attribute " & attr.Name & "='" & attr.Value & "'")
End Sub
|
|
|
|
|
A little confused...i dont know whether this can be used in my case..if so which piece of code
modified 6-Dec-11 5:19am.
|
|
|
|
|
I'll have to get back to you later tonight. Let me try to figure out exactly what your doing.
|
|
|
|
|