|
|
How can I call a static method from a user control (ascx) before loading the control in the page collection?
What I need to do is receive some data from the static method of the control prior to loading it into the Page.
regards,
Mircea
Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.
|
|
|
|
|
Refactor the code into its own class then call it on PreRender method of the Control you wish to load
Look where you want to go not where you don't want to crash.
Bikers Bible
|
|
|
|
|
The thing is that I need to call that method in a page that the control must not be shown.
regards,
Mircea
Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.
|
|
|
|
|
If you really must, then load the control into a panel, then hide the panel. You can then call the control from there.
Look where you want to go not where you don't want to crash.
Bikers Bible
|
|
|
|
|
Mircea Grelus wrote: What I need to do is receive some data from the static method of the control prior to loading it into the Page.
I'm not sure what is your purpose behind the sense, but you may try overriding the FrameworkInitialize method to call the static method of the user control. Basically, this method is called when the page control tree is built.
|
|
|
|
|
Managed to do it through Reflection. I changed the static method into a property and then:
Control ctrl = Page.LoadControl("~/Modules/SignIn.ascx");<br />
Type type = ctrl.GetType();<br />
System.Reflection.PropertyInfo info = type.GetProperty("Rights");<br />
string[] rights = (string[])info.GetValue(ctrl, null);
regards,
Mircea
Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.
|
|
|
|
|
IMO, reflection seems overkill in this case as you can cast the result of the LoadControl method to the user control type before you access its property/method. With the ASP.NET 2.0, you also need to use the Reference directive in the web page so that you use the user control type in the web page. Another option is that you can define an interface with the property and have the control implement the interface, then in the web page you can cast to the interface to use the property/method.
|
|
|
|
|
minhpc_bk wrote: you also need to use the Reference directive
Well I was trying to avoid that. Why? Because I'm using it in a page in a framework. The ideea is that after the framework is deployed other modules can be developed. So I don't really know what user controls I'm dealing with. All I need to do is receive some properties from that user control. All user controls developed for this framework inherit from a base class that property. So if it isn't defined in the control, I get the properties of the base class.
Probably this might be overkill by I see no other way of acomplishing this right now.
regards,
Mircea
Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.
|
|
|
|
|
Hello everyone,
I'm looking for a way to trigger a javascript confirmation dialog box and capture its value via a function as opposed to button events (as per all the tutorials I've found). The reasoning behind this is that are are 3 separate things that could trigger this dialog - 2 being button events, and one being page load if certain circumstances are met. Needless to say I don't want to write 3 separate functions for these if I don't have to, I'd rather just call the main confirm function from pageload and/or the button event handlers as appropriate.
Does anyone have any ideas? Thanks in advance!
-------------------
abort, retry, fail?
|
|
|
|
|
You could write two functions in form of a string, one is your confirm, and the other is the function that will capture the confirm value (val1, val2, etc). Then on the server side you will have to implement ICallbackEventHandler interface, incorporate the two methods that come with it (GetCallbackResult, and RaiseCallbackEvent).
Next, register your javascript(RegisterClientScriptBlock), then tie them all up in a string that holds the value of 'GetCallbackEventReference'. Once that's done, then you will want to add the GetCallbackEventReference string to a control's "onclick" attribute, OR you can place it within yet another javascript that will get triggered at some point in time... I know, this sounds a little confusing, but maybe if you give me the specifics of your project I could try to write it for you (I just did something very similar to this yesterday and it worked!)
Nila Fridley
|
|
|
|
|
Or you could just register a little js - no need to implement anything else....seems like you're over-complicating things a little
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
Rich, it all depends on exactly what he is intending on doing with the captured value... first off, he will have to write a function for the confirm, and one to capture value. Then if he needs to process the captured value on the server side, then he would most certainly need to create a 'receiver' js function, and give it an event reference, and call the referenced function from within the js that captures the value of the confirm. Without the event reference (or a complete page postback), the server won't be able to process anything.
When you think about even the smallest asynchronous functionalities, in pure english it sounds very easy, but translating it to .net is rather 'screwy'
Nila Fridley
|
|
|
|
|
Sorry, but I fail to see why the need for the complexity....
Define a js function....
function confirmDialog()
{
res = confirm(.......)
if (res)
{
document.getElementById ('someHiddenField').value = inputFromConfirm
}
}
Then to call the function, just set the onclick handler of the buttons, and in Page_Load, Page.RegisterStartupScript for the third case....
Once the function is called, can either __doPostback or just call the default button's click event - look for the hidden value on't server side, et voila!
Can you talk me through how you would implement this...why go to all the trouble and jumping through the hoops you seem to suggest?
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
Uhh, Rich... I'm way too tired to sit down and type up a long long chunk of code just to prove a silly point! If you think I'm making things complicated, and if you don't know how ICallbackEventHandler interface works, then just read this article:
http://www.codeguru.com/csharp/.net/net_asp/scripting/article.php/c11843/[^]
There are lots and lots of resources out there that shed light on asp.net's client callbacks
Nila
|
|
|
|
|
Oh calm down - I wasn't expecting you to give me chapter and verse - simpy trying to get a different perspective on things. That's one of the reasons why I like this place - since we can have an adult discussion about different approaches to a given problem. You obviously know something I don't, or are aware of a point I've missed, and I was only trying to engage you to discuss it.
I mean really - did you wake up one morning and suddenly know EVERYTHING, or have you spoken to others and learned from what they say?
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
Im sorry if my post sounded like that, I wasn't angry by any means, Im actually a super nice girl. I was just very tired after working a long day...
To answer your question on "did you wake up one morning and suddenly know EVERYTHING"; no, I am not the all-knowing since I am not God (not even close!). All I did was to try and help out some other person, but you had to start and argue with me.
Nila Fridley
|
|
|
|
|
Hello All,
Have some problem, and trying since last two days.
I have a xml file something like this:
I am puting just one node.
- <ROW>
<EVENT_ID>2054767</EVENT_ID>
<EVENT_STATUS>Completed</EVENT_STATUS>
<RESCHD_IND>Y</RESCHD_IND>
<VENUE_CHG_IND>N</VENUE_CHG_IND>
<EVENT_DT>09/23/2004</EVENT_DT>
<EVENT_START_TM>06:30:00 PM</EVENT_START_TM>
<EVENT_END_TM>09:30:00 PM</EVENT_END_TM>
- <CITY>
<CUST_ID>357363</CUST_ID>
<TBGID>1</TBGID>
</CITY>
</ROW>
earlier, I have only data upto <EVENT_END_TM>
and I am able to read it in my dataset easily, using the following code:
System.Xml.XmlNode xNode = somemethod;(this method fetch data from webservice-xml file)
XmlNodeReader xReader = new XmlNodeReader(xNode);
ds.ReadXml(xReader, System.Data.XmlReadMode.Auto);
And I am displaying it directly in datagrid by binding it with dataset.
but now, when I am binding it with datagrid with the same procedure, it only display the column headings, and no data in that.
Can anybody know, how to read this nested node data?
Thank you very much.
Robin
<div class="ForumSig"></div>
-- modified at 16:04 Friday 21st July, 2006
|
|
|
|
|
Have you specified an xPath to tell your datagrid which nodes to display from the XML doc? By default, datagrids show tag values and not the text within them.
Nila Fridley
|
|
|
|
|
Hi Nila,
Thanks for your help.But I am new in this xml field.If you can explain with a small example it will be a great help to me.
You know the xml file structure of my file.let say, i want to read first two value. can you pz explain using xpath?
Thanks
|
|
|
|
|
Hi Robin,
Sorry for getting back to you so late... if you are trying to capture EVEN_ID and EVENT_STATUS then you need xPath that reads something like this:
/ROW[position()<3]
However, if you want to capture CUST_ID and TBGID then your xPath should be as follows:
/ROW/CITY[position()<3]
xPath is pretty simple; it is the query language of XML, and there are may articles and tutorials available over the Internet in that subject. Just go to google.com and make a search for "xPath tutorial", you'll get a million hits! One site that I like the best is: http://www.w3.org/TR/xpath[^]
Hope that helped you
Nila
|
|
|
|
|
While using the Crystal Report SDK and Business Objects Enterprise XI R2 on a web site that is not hosted on the same machine as the Business Objects server all attempts to retrieve a report from any binding senario available from business objects all fail. A sample block of code for any who are curious.
<br />
string temp=null;<br />
string sampleReportName = "Report1.rpt <br />
SessionMgr sessionMgr = new SessionMgr();<br />
EnterpriseSession enterpriseSession;<br />
EnterpriseService enterpriseService;<br />
EnterpriseService RasService;<br />
InfoStore infoStore;<br />
nfoObjects infoObjects;<br />
InfoObject infoObject;<br />
<br />
ReportAppFactory reportAppFactory;<br />
ReportClientDocument reportClientDocument;<br />
enterpriseSession = sessionMgr.Logon (UserName,password,"BOHost","secEnterprise");<br />
<br />
try<br />
{ <br />
enterpriseService = enterpriseSession.GetService("BOHost","InfoStore");<br />
//the code dies here if it is hosted on a server other then the B.O. server<br />
RasService = enterpriseSession.GetService("BOHost",","RASReportFactory");<br />
<br />
infoStore = new InfoStore(enterpriseService);<br />
infoObjects = infoStore.Query("Select SI_ID From CI_INFOOBJECTS Where SI_NAME Like '" + sampleReportName +"'");<br />
<br />
infoObject = infoObjects[1];<br />
temp = infoObject.ID.ToString();<br />
<br />
reportAppFactory = (ReportAppFactory)RasService.Interface;<br />
reportClientDocument = reportAppFactory.OpenDocument(infoObject.ID,0);<br />
CrystalReportViewer1.ReportSource = reportClientDocument;<br />
}<br />
catch(Exception et)<br />
{<br />
temp =et.Message;<br />
enterpriseSession.Logoff(); <br />
}<br />
enterpriseSession.Logoff();<br />
I wish those dead beats at Business Objects would spend more time fixing their buggy products then going around advertising to all the idiot managers who think this product is the answer to all their problems. We have a saying for this in America that the French don't understand, its called "False Advertising" Thanks again. I will try to stop complaining.
nothing
|
|
|
|
|
In My App, we are reading data from database into a dataView and then binding it to repeater control.
now we want to implement column sort for repeater control.
i know, we can sort data by using dataview sort method.
my question is for each and every time user clicks on repeater column, do we need to make a database call to get data.
Is there some efficient way to store default dataview somewhere, before binding to repeater?
how far it is safe, to use session variable, viewstate variable etc?
Or is there any other alternative?
Thanks
MK
-- modified at 11:27 Monday 24th July, 2006
|
|
|
|
|
Part of it depends on the type of data. Is it sensitive? Session variables are an easy route but they expire after 20 minutes (unless you change the default setting). I'm not as familiar with viewstates as I either use a session variable or a query string.
|
|
|
|
|
Web Services can't return unknown(generic) types, a web service should explain it self all the time.
It means that what you are doing is not a good a idea
<br />
<WebMethod()> Public Function Test(ByVal sl() as TestList ) As String<br />
Return sL(1).Value.ToString<br />
End Function<br />
From application AppTest:
<br />
Dim param() As New ArrayList<br />
param.Add(New TestList("N1", "V1", "T1", "S1"))<br />
param.Add(New TestList("N2", "V2", "T2", "S2"))<br />
Response.Write( ws.Test(parm.ToArray( GetType(TestList) ) ) )<br />
I am assuming implicit convertion on of the Array with the array list but you can cast that array to any type you want before passing it to the web service.
Greetings ,
FMD
|
|
|
|