asp.net automatically open lightbox with the paramaters - asp.net

I have a page in c# that redirects to another page like
Response.Redirect("default.aspx?name=" + user.Firstname + "&surname=" + user.Lastname).
default.aspx has a lightbox. I want to open this lightbox when I redirect the page that include this lightbox. Also, I want to show the parameters in that lightbox input fields. Is there a way to achieve this?
Thanks for any help.

I am afraid you cannot do it with Lightbox.
Lightbox plugin works on <a> tag and fetches value form href attribute. Also it specially design for Images as you can see if you provide a URL to page it doesnt load it.
For Intance,
if you provide,
<a href="page.html" id="a1" >Click Me</a>
it will keep showing the loading page.
Instead try using thickbox to show the current user parameters.
For thickbox to show a page you can use
<script language="javascript" type="text/javascript" src="javascript/thickbox.js"></script>
<a id="a1" href="#" title="Click me" class="thickbox">Call me</a>
<script type="text/javascript" >
$(document).ready(function(){
var anchor = document.getElementById("a1");
var username= '<%= Request.QueryString["username"]%>';
var url="second.html?height=500&width=700&modal=true&TB_iframe=true&username="+username;
$('#a1').attr("href", url);
anchor.click();
});
</script>
Let me know if it worked.

Related

iframe that updates html

I am trying to build an iframe that reacts to the URL that is being inputted.
For example if the user goes to:
domainA.com/somethingnice then the iframe src should be sub.domainB.com/somethingnice
so basically always following the path.
I also plan to use javascript to hide the frame src - something like this:
<script type="text/javascript">
$(document).ready(function(e) {
$('iframe').attr('src','https://sub.domainB.com/');
});
</script>
<body>
<iframe src="" />
</body>
But I have no clue even where to start in making that src to change based on the user's links or inputs.
Any ideas are really welcome!
BTW: the src should NOT change if the users click anywhere inside the iframe - it should act just like a normal wesbite. Only when they follow an external (or direct) link to that subdomain the src for the iframe should be rewritten
Thank you!

dijit.form.DateTextBox is not visible when the page is loaded

When my page is loaded I cannot see calendar:
When I click on the birthday field of the form it appears, but it does not look as I expect:
The code I use to display in jsp file:
<label for="birthday">Birthday<br/> </label>
<sf:input path="birthday" id="birthday"
pattern="(0[1-9]|1[0-9]|2[0-9]|3[01])-(0[1-9]|1[012])-[0-9]{4}"/><br/>
<script type="text/javascript">
Spring.addDecoration(new Spring.ElementDecoration({
elementId:"birthday",
widgetType:"dijit.form.DateTextBox",
widgetAttrs:{ datePattern:"dd-MM-yyyy", required:true }}));
</script>
So my questions are:
How to make calendar always visible as soon as the form is loaded?
How can I manage with its css, so I could set backgournd and other properties via css file? If it is not possible, then via JavaScript params.
Thanks.
In order the calendar works I had to set the following css class to the html body element:
<body class="tundra">
It helped.

asp.net code behind show images from DB wrapped by lightbox

I am writing an web app in asp.net,
I have in my DB URL of my images and I want to
display all the images from my DB wrapped with lightbox my code so far is:
<script type="text/javascript" src="Lightbox/js/prototype.js"></script>
<script type="text/javascript" src="Lightbox/js/scriptaculous.js?load=effects,builder> </script>
<script type="text/javascript" src="Lightbox/js/lightbox.js"></script>
<a rel="lightbox" id="userImageLightBox" runat="server" title="profile image">
<img id="userImage" runat="server" width="150" height="146" alt="" src=""/>
</a>
so my question is:
how can i insert all my images using foreach from the code behind, that when i click on the
image the lightbox will activate
thanks
Use a ListView which will give you total control over the markup as well as clean HTML. Use a HttpHandler (other Q's on SO on this topic - do a search) to retrieve image from DB and serve it up.
In your ListView, use ItemTemplates to contain markup for each image. Images can be obtained by using the following syntax for each img source attribute.
src='ImageHandler.ashx?imageID=<%# Eval("ImageName")%>'

Access to events?

i have a question about generating images at runtime which are also links. Ok, so what i was going to do was create an ImageButton, and then set the onClick event to something such as:
window.open('http://www.themagicfinger.com/')
Which means it would look like:
newImage.Click += (window.open('http://www.themagicfinger.com/'));
But then i realised that this doesnt work, because it looks for a method which matches the event delagate.
So my question is, is this the best way to achieve what i want, and if so, how can i make it work?
Another option that came in my head would be to wrap the image in an tag, but i think this way its better.
Thanks
What you need is OnClientClick:
<asp:ImageButton id="ImageButton1" runat="server" OnClientClick="window.open('http://www.themagicfinger.com/'); return false;" ImageUrl="MyButton.png" />
This property is a string, not event, and you can also assign it from within the code behind:
ImageButton1.OnClientClick = "window.open('http://www.themagicfinger.com/'); return false;";
If you're asking how to use server-side code to tell the client to open a browser window, you can't. The server-side code has no means of telling the client to do that. The only thing you'd be able to do from server-side code is emit client-side that does this. And in that case, why use the server-side code at all?
Using jQuery for example, you can attach the click event like this:
<!-- page header (including loading jQuery), other stuff that's before the image, etc. -->
<img src="/path/to/image" alt="some text" id="imgOpenWindow" />
<!-- the rest of the page -->
<script type="text/javascript">
$(document).ready(function() {
$('#imgOpenWindow').click(function(){
window.open('http://www.themagicfinger.com/');
});
});
</script>
If for some reason you need to use an ImageButton control for this then it would look like this:
<!-- page header (including loading jQuery), other stuff that's before the image, etc. -->
<asp:ImageButton run="server" id="imgOpenWindow" ImageUrl="/path/to/image" AlternateText="some text" />
<!-- the rest of the page -->
<script type="text/javascript">
$(document).ready(function() {
$('#<%= imgOpenWindow.ClientID %>').click(function(){
window.open('http://www.themagicfinger.com/');
});
});
</script>
But I'm not sure what the behavior would be with the post-back. It might override the JavaScript handler (by posting back before your handler is executed) or post-back after the window opens, etc. I would consider that behavior to be undefined and unreliable. An Image control will do the trick, though, if you don't need the button post-back capabilities.

How do I set the target frame for form submission in ASP.NET?

I have an asp.net page in an iframe where all links target _blank
<base target="_blank" />
But I want the form on it to submit to _self (i.e. the iframe where the page is located) when the one button is clicked. The form is an <asp:Panel> with an <asp:Button> control for submitting it.
Where can I set the target for this form? Since there isn't a <form> tag or an <input> tag in the file (ASP.NET makes them when it renders the page), I don't know how to change the target to override my <base> tag.
I'm not sure if I understood you right, but you can set the target in the form tag, like this:
<form method=post action="Page.aspx" target="_self">
I just found this post on the asp.net forums by mokeefe that changes the target by javascript.
I just put it in my page and tried it. I had to make these modifications:
1. I'm using asp tags only, so I have <asp:Button> not <input type="button"> and my onclick has to be the server-side method I'm calling on submission. Therefore I put this new javascript in OnClientClick:
<asp:Button ID="cmdEmailSearch" runat="server" Text="Search"
OnClick="cmdEmailSearch_Click"
OnClientClick="javascript:pageSubmit()"/>
2. I removed the myForm.submit() since ASP.NET renders the page putting the WebForm_DoPostBackWithOptions() javascript in the button's onclick right after it puts my pageSubmit()
<script type="text/javascript">
function pageSubmit(){
// where form1 is the Parent Form Id
var myForm = document.getElementById('form1');
myForm.target = '_self';
}// end function
</script>

Resources